{"action":"created","issue":{"url":"https://api.github.com/repos/lpabon/cmockery2/issues/16","labels_url":"https://api.github.com/repos/lpabon/cmockery2/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/lpabon/cmockery2/issues/16/comments","events_url":"https://api.github.com/repos/lpabon/cmockery2/issues/16/events","html_url":"https://github.com/lpabon/cmockery2/issues/16","id":50482426,"number":16,"title":"a question for help","user":{"login":"j123kaishichufa","id":4859208,"avatar_url":"https://avatars.githubusercontent.com/u/4859208?v=3","gravatar_id":"","url":"https://api.github.com/users/j123kaishichufa","html_url":"https://github.com/j123kaishichufa","followers_url":"https://api.github.com/users/j123kaishichufa/followers","following_url":"https://api.github.com/users/j123kaishichufa/following{/other_user}","gists_url":"https://api.github.com/users/j123kaishichufa/gists{/gist_id}","starred_url":"https://api.github.com/users/j123kaishichufa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j123kaishichufa/subscriptions","organizations_url":"https://api.github.com/users/j123kaishichufa/orgs","repos_url":"https://api.github.com/users/j123kaishichufa/repos","events_url":"https://api.github.com/users/j123kaishichufa/events{/privacy}","received_events_url":"https://api.github.com/users/j123kaishichufa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lpabon/cmockery2/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"lpabon","id":3880001,"avatar_url":"https://avatars.githubusercontent.com/u/3880001?v=3","gravatar_id":"","url":"https://api.github.com/users/lpabon","html_url":"https://github.com/lpabon","followers_url":"https://api.github.com/users/lpabon/followers","following_url":"https://api.github.com/users/lpabon/following{/other_user}","gists_url":"https://api.github.com/users/lpabon/gists{/gist_id}","starred_url":"https://api.github.com/users/lpabon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpabon/subscriptions","organizations_url":"https://api.github.com/users/lpabon/orgs","repos_url":"https://api.github.com/users/lpabon/repos","events_url":"https://api.github.com/users/lpabon/events{/privacy}","received_events_url":"https://api.github.com/users/lpabon/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2014-12-01T02:45:55Z","updated_at":"2015-01-09T05:39:25Z","closed_at":"2014-12-04T04:34:38Z","body":"\r\nhi,\r\ni do not know how to raise a question for help using cmockery2 in github, so i raise the question here. if it is not proper, please forgive me.\r\n\r\nin my test, i wan to test that funa indeed called funcb successfully.  i meet a puzzle in my test , the souce code(func.c test.c) is as follow:\r\n\r\n//func.c\r\n\r\n#include\r\nvoid funcb(int para)\r\n{\r\npara = para+10;\r\nprintf(\"real funcb\\n\");\r\n}\r\nvoid funca()\r\n{\r\nint msg = 10;\r\nfuncb(msg);\r\n}\r\n\r\n//test.c\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include \"cmockery.h\"\r\n//#include\r\n//#define UNIT_TESTING 1\r\n\r\n//#if UNIT_TESTING\r\n//#include \"cmockery_override.h\"\r\n//#endif\r\n//#include\r\n\r\nextern void funca();\r\n//extern static void funcb(int para);\r\n//mock funcb\r\nstatic void funcb(int para)\r\n{\r\nprintf(\"*************\");\r\ncheck_expected(para);\r\n}\r\n\r\n//test\r\nvoid test_funca(void ** state)\r\n{\r\nexpect_value(funcb, para, 10);\r\nfunca();\r\n}\r\n\r\nint main()\r\n{\r\nconst UnitTest tests[]={unit_test(test_funca)};\r\nreturn run_tests(tests,\"report\");\r\n}\r\n\r\ni want to test funca. when i run test, i found funca in test.c called the funcb in funcc.c, but not the mock funb. why?\r\n thank you very much.\r\n"},"comment":{"url":"https://api.github.com/repos/lpabon/cmockery2/issues/comments/69295582","html_url":"https://github.com/lpabon/cmockery2/issues/16#issuecomment-69295582","issue_url":"https://api.github.com/repos/lpabon/cmockery2/issues/16","id":69295582,"user":{"login":"j123kaishichufa","id":4859208,"avatar_url":"https://avatars.githubusercontent.com/u/4859208?v=3","gravatar_id":"","url":"https://api.github.com/users/j123kaishichufa","html_url":"https://github.com/j123kaishichufa","followers_url":"https://api.github.com/users/j123kaishichufa/followers","following_url":"https://api.github.com/users/j123kaishichufa/following{/other_user}","gists_url":"https://api.github.com/users/j123kaishichufa/gists{/gist_id}","starred_url":"https://api.github.com/users/j123kaishichufa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j123kaishichufa/subscriptions","organizations_url":"https://api.github.com/users/j123kaishichufa/orgs","repos_url":"https://api.github.com/users/j123kaishichufa/repos","events_url":"https://api.github.com/users/j123kaishichufa/events{/privacy}","received_events_url":"https://api.github.com/users/j123kaishichufa/received_events","type":"User","site_admin":false},"created_at":"2015-01-09T05:39:25Z","updated_at":"2015-01-09T05:39:25Z","body":"I have tried  this way as you said. It does  work well.  Thank you. \r\n\r\n\r\nI also sovle this  problem by adding macro to real funcb.  Let the complier does not compile the real funcb but the mocked funcb.\r\n\r\n//func.c\r\n# ifndef UNIT_TESTING \r\nvoid funcb(int para)\r\n{\r\npara = para+10;\r\nprintf(\"real funcb\\n\");\r\n}\r\n#endif\r\n\r\nvoid funca() \r\n{\r\nint msg = 10;\r\nfuncb(msg);\r\n}\r\n\r\nin test.c,   #define UNIT_TESTING 1\r\n\r\n\r\n    But , from our users's view,  the method you said or my macro solution above, has slightly changged the structure of  the tested program files. \r\n    I think that whether cmockery can provide a internal mechanism to avoid modiying the structure of  the tested program files, neither needing splitting the function nor adding macro explicitly.\r\n   I don't know wheter my thought is reasonable or not.  Just only express my  idea without other purpose.\r\n   Thank you again for your reply. "}}