Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit test cleanup for single method

Tags:

java

junit

I have a JUnit test class with a number of different test cases. One of these test cases has bit different test setup and cleanup than the other ones. What is the best way to do test cleanup in such scenario? Extract test case into separate class and use standard @Before and @After annotations?

like image 999
czajek Avatar asked Nov 30 '25 05:11

czajek


1 Answers

Make a subclass with only that test, write custom @Before and @After methods calling super ones if needed.

like image 113
Simimmo Avatar answered Dec 01 '25 20:12

Simimmo