1

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.

Charuක
  • 12,953
  • 5
  • 50
  • 88
Suvi_Eu
  • 255
  • 1
  • 3
  • 16
  • Where are you reading the docs? I can see `mock().expectNCalls(5, "productionCode");` and ``mock().ignoreOtherCalls();` but not `expectNoCall`. – doctorlove Dec 23 '16 at 10:17
  • https://cpputest.github.io/mocking_manual.html in last Last paragraph. With the tittle: "Miscellaneous" and then, under a little explanation (one line or two aprox). – Suvi_Eu Dec 23 '16 at 12:03
  • Maybe expectNoCall is not done for this. But I would like to ignore one call placed between other ones that I want to call under the same case test. If I use ignoreothercalls I have not clear if the rest of the calls, following this, will be called. I need the rest, after ignored call, will be called. Or at least, to find the way of stopping ignoreothercalls effect before the end ot the test case. – Suvi_Eu Dec 23 '16 at 12:13
  • Can you provide a small example that exhibits the same problem? – doctorlove Dec 23 '16 at 12:16
  • Yes, I have created another thread question separate from this question because they are two different questions: http://stackoverflow.com/questions/41301539/cpputest-how-to-ignore-only-one-call-placed-between-other-ones – Suvi_Eu Dec 23 '16 at 12:32
  • I too would like to use expectNoCall, but it's not present in the version I've just downloaded. I'm testing C++. – Richard Whitehead Nov 15 '19 at 13:36

1 Answers1

1

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.

Felipe Lavratti
  • 2,887
  • 16
  • 34
  • My test file is .c and the only instruction it doesn't like was expectNocall. The rest of mock().X works propperly. – Suvi_Eu Jan 02 '17 at 08:13