1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 00:15:58 +01:00

Merge pull request #245 from jsalling/feature/teardown-not-ignore

Always run the tearDown() even if test is ignored
This commit is contained in:
Mark VanderVoord
2017-01-13 15:43:26 -05:00
committed by GitHub
4 changed files with 8 additions and 4 deletions

View File

@@ -276,7 +276,7 @@ class UnityTestRunnerGenerator
output.puts(" TestFunc(#{va_args2}); \\")
output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
output.puts(" } \\")
output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
output.puts(" if (TEST_PROTECT()) \\")
output.puts(" { \\")
output.puts(" #{@options[:teardown_name]}(); \\")
output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)

View File

@@ -1231,7 +1231,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
setUp();
Func();
}
if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
if (TEST_PROTECT())
{
tearDown();
}

View File

@@ -183,9 +183,9 @@ void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void)
void test_ShouldCallMockInitAndVerifyFunctionsForEachTest(void)
{
int passes = (int)(Unity.NumberOfTests - Unity.TestFailures - Unity.TestIgnores);
int passesOrIgnores = (int)(Unity.NumberOfTests - Unity.TestFailures);
TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests, mockMock_Init_Counter, "Mock Init Should Be Called Once Per Test Started");
TEST_ASSERT_EQUAL_MESSAGE(passes, mockMock_Verify_Counter, "Mock Verify Should Be Called Once Per Test Passed");
TEST_ASSERT_EQUAL_MESSAGE(passesOrIgnores, mockMock_Verify_Counter, "Mock Verify Should Be Called Once Per Test Passed");
TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests - 1, mockMock_Destroy_Counter, "Mock Destroy Should Be Called Once Per Test Completed");
TEST_ASSERT_EQUAL_MESSAGE(0, CMockMemFreeFinalCounter, "Mock MemFreeFinal Should Not Be Called Until End");
}

View File

@@ -67,7 +67,11 @@ void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");