Cpputest: how to compile and use expectNoCall?

695 views Asked by At

I have wrote the syntax: mock().expectNoCall("productionCode") as Cpputest.org page says. But the compiler says that mocksupport class doesn't support this type of order.

test_RFID_Drv.c:322:9: error: ‘class MockSupport’ has no member named ‘expectNoCall’mock().expectNoCall("HAL_AS393x_ReadRegisters");

How can it be used? Must I include some file at headers? Currently I have those ones for mocking:

/*! \include <CppUTest/CommandLineTestRunner.h> */
#include <CppUTest/CommandLineTestRunner.h>
/*! \include <CppUTest/TestHarness.h> */
#include <CppUTest/TestHarness.h> 
/*! \include <CppUTestExt/MockSupport.h> */
#include <CppUTestExt/MockSupport.h>

The thing is that I want to ignore one concret system call. I don't want to test it.

1

There are 1 answers

1
Felipe Lavratti On

Eugenia, You are in a '.c' file, mock().expectXX is a syntax for '.cpp' files.

This is a working example of no expectations in a .cpp file.

If you need to use mock from .c files, include "MockSupport_c.h" and make sure you use the correct c syntax, read the header here.

If you don't want to use the syntax of the "_c" header, make your mocks file a .cpp and add the export "C" linker modifier to your mocked function, such as I did here.