I'm trying out testing Java Swing with Fest. My problem is that closing the frame fixture ( frameFixture.close()
) as a part of @After tearDown()
method of my tests somehow blocks/hides/consumes (don't know which one) the console output from the test classes runner.
( That is printout derived from Result result = JUnitCore.runClasses(testClasses)
).
Any idea what might be the cause? Below are the relevant setUp() and tearDown() methods, as well as piece of code running all tests and printing out the aggregate results, or what gets mysteriously suppressed by (presumably) Fest.
setUp() and tearDown()
of test class:
@Before
public void setUp() {
this.frameFixture = new FrameFixture( new DesktopView() ) ;
this.frameFixture.show() ;
}
@After
public void tearDown() {
this.frameFixture.close() ;
this.frameFixture = null ;
}
Tests summary from the tests classes runner (that gets suppressed when I call frameFixture.close()
) :
Result result = JUnitCore.runClasses(testClasses) ;
for( Failure failure : result.getFailures() ) {
System.out.println( failure.toString() ) ;
}
System.out.println("Tests called: " + result.getRunCount() ) ;
System.out.println("Tests failed: " + result.getFailureCount() ) ;
System.out.println("Execution time: " + result.getRunTime() + " ms" ) ;
System.out.println( "All tests passed: " + result.wasSuccessful() ) ;
I don't have enough reputation score to add a comment, so I'll add my notes to the answer.
It could that the System.exit() is called when your main frame gets closed, for example, if it's been created with JFrame.EXIT_ON_CLOSE option. If this is the case, then check how to handle System.exit() with FEST.