也许有人有使用cpputest进行单元测试的经验。
我有这样的事情:
被测源代码:
main_function()
{
static int8 is_functioncalled = 1;
if (is_functioncalled){
my_local_function();
is_functioncalled = 0
}
单元测试环境:
TEST(TESTGROUP,TEST_CASE1){
//Some Unit Test checks of my_local_function()
main_function();
}
TEST(TESTGROUP,TEST_CASE2){
//Some other Unit Test stuff
main_function(); // --> my_local_function() will not be called in this test case because it's called already before
}
我需要在 TEST_CASE2 中再次调用函数my_local_function() 。该函数通过公共接口main_function()间接调用,该接口可在单元测试中直接调用。有没有人知道如何在一般情况下或在cpputest环境中执行此操作?