I am using Java util logging (JUL) in a Junit test class with JUL working in default config (i.e. printing to console).
Logs statements from methods annotated with @BeforeClass
and @AfterClass
are getting printed when they are executed but logs in '@Test' methods are printed only after all test execution is finished.
Not sure what exactly is wrong because the same were working earlier.
Logger instantiation:
private static Logger logger = Logger.getLogger(MainIntegrationTest.class.getName());
Logger use:
logger.info("start test");
The test cases are run using maven. I noticed that this started happening only after I started running the test classes in parallel using this surefire configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<parallel>classes</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
The logs are printed at test execution time if I run the test classes in serial fashion.