umock-c
umock-c copied to clipboard
Add a function to negative_tests to get a call description (using stringify)
This will help identifying the offending STRICT_EXPECTED_CALL when defining negative tests.
Example:
...
umock_c_negative_tests_snapshot();
size_t call_count = umock_c_negative_tests_call_count();
//act
for (size_t i = 0; i < call_count; i++)
{
if (umock_c_negative_tests_can_call_fail(i))
{
// arrange
char error_msg[128];
char* call_description = umock_c_negative_tests_get_call_description(i);
(void)sprintf(error_msg, "Failure in test %zu/%zu (%s)", i, call_count, call_description);
my_gballoc_free(call_description);
umock_c_negative_tests_reset();
umock_c_negative_tests_fail_call(i);
int result = call_my_public_function();
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result, error_msg);
}
}
Nice initiative, ty! Had some comments about specs, tests and a little bit of poetry in the mix.
This is a rather stale PR, closing.