JUnit: @Before only for some test methods?

前端 未结 6 1402
我寻月下人不归
我寻月下人不归 2020-12-30 18:29

I have some common set up code that I\'ve factored out to a method marked with @Before. However, it is not necessary for all this code to run for every single t

6条回答
  •  一向
    一向 (楼主)
    2020-12-30 19:20

    Not sure about @Before, but I recently came up with a strategy for @After block to run selectively. The implementation was straight forward. I have some flags set to default values as part of the test class. They are reset to default values in @Before class. In the class I need to do things specific to a flag, I set those flags & in @After I check for flag values to do the respective jobs.

提交回复
热议问题