2
我想編譯我的測試組項目,但我沒有成功,因爲下一個編譯錯誤,我不明白在輸出:模擬()。啓用和禁用無法識別編譯與cpputest庫測試組項目
控制檯輸出:
"test_TestHW.c: In member function ‘virtual void TEST_TestHW_TestHW_main_Test::testBody()’:
test_TestHW.c:617:6: error: request for member ‘enable’ in ‘mock’, which is
of non-class type ‘MockSupport&(const SimpleString&, MockFailureReporter*)’
mock.enable();
^
test_TestHW.c:651:6: error: request for member ‘disable’ in ‘mock’, which is of non-class
type ‘MockSupport&(const SimpleString&, MockFailureReporter*)’
mock.disable();"
的項目代碼部分:
測試組代碼.c文件。
/*******************************************************************************
* INCLUDES
*******************************************************************************/
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/TestHarness.h>
#include <CppUTestExt/MockSupport.h>
extern "C"
{
#include "RFID_Drv.h"
#include "HAL_AS393x_mock.h"
}
TEST_GROUP (TestHW)
{
protected:
public:
/* Define data accessible to test group members here */
void setup()
{
mock().disable();
}
void teardown()
{
/* Clean up steps are executed after each TEST */
mock().checkExpectations();
mock().clear();
}
};
TEST(TestHW,TestHW_main_FC_cuenta)
{
unsigned char error_val;
FLAG_Ocupado =0;
ControlEmi = 150; /* Valor de frecuencia para probar */
mock.enable();
mock().expectOneCall("CapturaTimer").andReturnValue(1000);
error_val=TestHW();
CHECK_EQUAL(error_val,FCENTRAL_CUENTA) /* Entra en el esatdo 2 */
CHECK_EQUAL(ControlEmi, 150);
mock.disable();
}
.......
//more test cases here
.......
int main(int ac, char** av)
{
/* Executes all the tests */
CommandLineTestRunner::RunAllTests(ac,av);
/* Returns value */
return(0);
}
包括mock.c文件:
/*******************************************************************************
* INCLUDES
*******************************************************************************/
#include <CppUTest/TestHarness.h>
#include <CppUTestExt/MockSupport.h>
extern "C"
{
#include "timer_mock.h"
}
unsigned long CapturaTimer(void)
{
mock().actualCall("CapturaTimer");
return mock().unsignedIntReturnValue();
}
看來,啓用/禁用不考慮和cpputest未知。我認爲這可能是我錯過的一件愚蠢的事情。但現在我無法看清楚。
我知道我正在測試Cpp測試文件中的C源函數。由於這是我使用了extern c實例。我很驚訝,因爲dis/en不被識別,但Mock()。expectonecall被識別(沒有編譯錯誤)。
- 因此,將有另一種方法來禁用/禁用目前 情況下的嘲笑?
- 可以看到包括cpputest相關 依賴關係等方面的一些錯誤?如果有可能如何解決它們?
它完成了嗎?我不確定我是否有。 –