I have a simple JUnit test which is ran by Maven through a method marked by @Test annotation. I want to place the shutdown hook into that test because I want to print some test results if the user hits CTRL-C. I code the following lines:
@Test
public void runTest() {
Thread shutdownHook = new Thread()
{
@Override
public void run()
{
System.out.println("hooked");
... print something via System.out.println ...
}
};
Runtime.getRuntime().addShutdownHook(shutdownHook);
... run test ...
}
To run it I use Maven:
mvn clean test -DtestClassName=com.MyTest
The problem is that nothing is printed. Looks like System.out.println is not working already. What can I do to fix it?