I don't know of any standard way to do this with JUnit. The reason for this, as you probably already know, is that your test cases should run independently. This applies to the “normal” setup / break methods that are performed before and after each test method. Class setup and decompression are slightly different, though, although I would prefer to run my tests myself and stay out of the problem zone.
However, if you are really sure of what you are doing, you can use the global flag to signal whether the class should be started / disabled, and check its status in the class settings / deletion methods. In your test case, you can include a special class as the very first one, which does nothing more than configure and sets a global flag to show real test cases that their class installation / removal methods should not be executed. Similarly, the special last class in the package can execute break code. The bottom line is that I'm afraid that JUnit does not guarantee the execution order of test classes inside the package, although most likely it will execute them in the specified order, but this is just an implementation detail. Try it, it may work for you - but there is no guarantee that he will always do what you expect.
Péter Török
source share