I am making unit tests in an Ada application in an existing suite based on aunit. According to their documentation and code, the procedures: Set_Up_Case and Tear_Down_Case should only run before the set of test routines. However, when I run the unit-tests (specific class or SmokeTests), then I see, they are run before and after each test. Stripped output:
2021-07-05 15:05:55 ----- Set_Up_Case -----
2021-07-05 15:05:55 ----- Set_Up -----
2021-07-05 15:05:58 ----- Starting Test AAAA -----
2021-07-05 15:06:07 ----- Tear_Down -----
2021-07-05 15:06:07 ----- Tear_Down_Case -----
2021-07-05 15:06:07 ----- Set_Up_Case -----
2021-07-05 15:06:07 ----- Set_Up -----
2021-07-05 15:06:10 ----- Starting Test BBBB -----
2021-07-05 15:06:34 ----- Tear_Down -----
2021-07-05 15:06:34 ----- Tear_Down_Case -----
So how can I get the behaviour as documented?
The
Set_Up_Case
andTear_Down_Case
routines are run at the start and end of a test case. TheSet_Up
andTear_Down
routines are run before and after a specific test routine within a test case. This is best illustrated using the minimal example shown below. The example borrows quite some example code from the AUnit cookbook.tests.ads (a new test case that contains 3 test routines:
Test_A
,Test_B
andTest_C
)tests.adb (the implementation of the test case and its test routines)
a_suite.ads (a new test suite)
a_suite.adb (the test suite contains 1 test case:
Tests
)main.adb (the test driver)
output