提交 d4197dac 编写于 作者: M Mark VanderVoord

There was no reason that CMock init and destroy calls should be in the...

There was no reason that CMock init and destroy calls should be in the protected blocks. teardown is more flexible if verify is called afterwards.
上级 a77f0308
...@@ -230,21 +230,21 @@ class UnityTestRunnerGenerator ...@@ -230,21 +230,21 @@ class UnityTestRunnerGenerator
output.puts(" Unity.CurrentTestName = #TestFunc#{va_args2.empty? ? '' : " \"(\" ##{va_args2} \")\""}; \\") output.puts(" Unity.CurrentTestName = #TestFunc#{va_args2.empty? ? '' : " \"(\" ##{va_args2} \")\""}; \\")
output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\") output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
output.puts(" Unity.NumberOfTests++; \\") output.puts(" Unity.NumberOfTests++; \\")
output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
output.puts(" if (TEST_PROTECT()) \\") output.puts(" if (TEST_PROTECT()) \\")
output.puts(" { \\") output.puts(" { \\")
output.puts(" CEXCEPTION_T e; \\") if cexception output.puts(" CEXCEPTION_T e; \\") if cexception
output.puts(" Try { \\") if cexception output.puts(" Try { \\") if cexception
output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
output.puts(" setUp(); \\") output.puts(" setUp(); \\")
output.puts(" TestFunc(#{va_args2}); \\") output.puts(" TestFunc(#{va_args2}); \\")
output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
output.puts(" } \\") output.puts(" } \\")
output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\") output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
output.puts(" { \\") output.puts(" { \\")
output.puts(" tearDown(); \\") output.puts(" tearDown(); \\")
output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
output.puts(" } \\") output.puts(" } \\")
output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
output.puts(" UnityConcludeTest(); \\") output.puts(" UnityConcludeTest(); \\")
output.puts("}\n") output.puts("}\n")
end end
......
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CEXCEPTION_T e; \ CEXCEPTION_T e; \
Try { \ Try { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CEXCEPTION_T e; \ CEXCEPTION_T e; \
Try { \ Try { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -7,18 +7,18 @@ ...@@ -7,18 +7,18 @@
Unity.CurrentTestName = #TestFunc "(" #__VA_ARGS__ ")"; \ Unity.CurrentTestName = #TestFunc "(" #__VA_ARGS__ ")"; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(__VA_ARGS__); \ TestFunc(__VA_ARGS__); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CEXCEPTION_T e; \ CEXCEPTION_T e; \
Try { \ Try { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
Unity.CurrentTestName = #TestFunc; \ Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \ Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \ Unity.NumberOfTests++; \
CMock_Init(); \
if (TEST_PROTECT()) \ if (TEST_PROTECT()) \
{ \ { \
CEXCEPTION_T e; \ CEXCEPTION_T e; \
Try { \ Try { \
CMock_Init(); \
setUp(); \ setUp(); \
TestFunc(); \ TestFunc(); \
CMock_Verify(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \ } \
CMock_Destroy(); \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \ { \
tearDown(); \ tearDown(); \
CMock_Verify(); \
} \ } \
CMock_Destroy(); \
UnityConcludeTest(); \ UnityConcludeTest(); \
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册