Skip to content

How to define setup/teardown for suites / run sessions with munit ? #4

@lczub

Description

@lczub

MUnit tests often requires time consuming preparation ( e.g. starting an application, create design), which not all test cases want to do each time in their setup. Same situation exist for cleanups ( close applications, delete designs) and test case teardown.

Other frameworks like pytest allows to define not only for the test itself a setup / teardown, even for suites and run sessions pytest - Fixture scopes

Question is, which concept has MUnit for this?

Checking the one_time_set_up() and one_time_tear_down() functions shows, that these steps are not executed in each run. It requires that a run with other test classes are executed before or afterwards.

  • one_time_tear_down() is only executed, when another test class is running afterwards
  • one_time_set_up() is only executed, when another test class is running afterwards
  • sample code see one_time_munit_samples.magik
MagikSF> one_time_munit_sample_01.run()
$
one_time_munit_sample_01.one_time_set_up()
one_time_munit_sample_01.set_up()
test_sample_1()
one_time_munit_sample_01.tear_down()
one_time_munit_sample_01.set_up()
test_sample_3()
one_time_munit_sample_01.tear_down()
a sw:mtest_result 
MagikSF> one_time_munit_sample_01.run()
$
one_time_munit_sample_01.set_up()
test_sample_1()
one_time_munit_sample_01.tear_down()
one_time_munit_sample_01.set_up()
test_sample_3()
one_time_munit_sample_01.tear_down()
a sw:mtest_result 
MagikSF> one_time_munit_sample_02.run()
$
one_time_munit_sample_01.one_time_tear_down()
one_time_munit_sample_02.one_time_set_up()
one_time_munit_sample_02.set_up()
test_sample_2()
one_time_munit_sample_02.tear_down()
one_time_munit_sample_02.set_up()
test_sample_4()
one_time_munit_sample_02.tear_down()
a sw:mtest_result 
MagikSF> one_time_munit_sample_01.run()
$
one_time_munit_sample_02.one_time_tear_down()
one_time_munit_sample_01.one_time_set_up()
one_time_munit_sample_01.set_up()
test_sample_1()
one_time_munit_sample_01.tear_down()
one_time_munit_sample_01.set_up()
test_sample_3()
one_time_munit_sample_01.tear_down()
a sw:mtest_result 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions