I have a java package which contains all my test case classes. Each class contains a lot of test cases. Each class is loaded and run one by one by JUnit. However each of the classes contains common configuration code which is run again and again and initialised everytime each of the classes are run.
These initializations take a lot of time.
Is there some way to load these configuration changes first and then run the test case so that I do not need to load them everytime.
JUnit4 has @BeforeClass annotation.
Just do something like this:
Method marked with
@BeforeClasswill run only once. Just make sure you use JUnit4.Update:
Also note, that it should be static, and as @ChristopheRoussy mentioned, you can use @AfterClass to destroy your common setup.