How to pre-define the running sequences of junit test cases?

后端 未结 5 1787
无人及你
无人及你 2021-01-11 09:44

I have a test class in java and there are several methods annotated by @Test in it, somehow, i want to Junit run method A before method B when i run the whole tests. Is it p

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 10:13

    Tests should have independent order, but some times we have not what we want. If you have a large legacy project with thousands of tests, and they depends on their execution order, you will have many problems, when, for example you will try to migrate on java 7, because it will shuffle all tests.

    You can read more about this problem here:

    junit test ordering and java 7

提交回复
热议问题