for JUnit 5 is it possible to create a class which executed (an object of this class...) before any of the junit tests are executed? In my case I would like to setup some logging before the tests start. I can do it with sortof a singleton, but I think, more elegant would be such a 'global start class'. Thanks Rene
I tried some google searches and checked the documentation but didn't find a hint.
Answer
The easiest approach would probably be to use the JUnit Platform Suite Engine, and perform all the initializations you want in a @BeforeSuite
method:
@Suite
@SuiteDisplayName("Suite with logging")
@SelectPackages("org.example")
class LoggingSuite {
@BeforeSuite
public void setUpLogging() {
// code to set up logging...
}
}