Config A unittest¶
Modify test.ini in unittest folder
Config source code¶
unittest could be performed on a single C file or multiple C files In [source] section,to add files for test
[source]
demo1.c
demo2.c
Config auto mock¶
ctestcode can auto mock function during compiling
In [auto_mock] section, to add functions for auto mock
[auto_mock]
myfunction
getLevel
Config exclude mock¶
In [exclude_mock] section, to add functions for exclude mock
[exclude_mock]
myfunction
Config libs¶
In [libs] section, to add static libs or dynamic libs
[libs]
-lpthread
mylib.a
Config real/mock switch¶
In [real_mock] section, to add functions for real/mock switch
[real_mock]
myfunction
getLevel
you could use blew macro to enable/disable mock
TEST(THE_UNIT,mytest)
{
MOCK_ON(myfunction);
MOCK_OFF(myfunction);
ALL_MOCK_ON();
ALL_MOCK_OFF();
}
Config MACRO¶
In [define] section, to add macro for the unittest
[define]
MYVALUE=1
MY_FLAG
Config include path¶
In [include_path] section, to add path for include This usually is done by ctestcode, you do not need to modify it .
[include_path]
{source_code}/mypath
Config compilation flags¶
In [flags] section, to add flags for compilation。default is ‘-g’
-g -O2