Log information inside a JUnit Suite

Posted by Alex Marinescu on Stack Overflow See other posts from Stack Overflow or by Alex Marinescu
Published on 2010-06-09T12:37:28Z Indexed on 2010/06/09 14:32 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

I'm currently trying to write inside a log file the total number of failed tests from a JUnite Suite.

My testsuite is defined as follows:

@RunWith(Suite.class)
@SuiteClasses({Class1.class, Class2.class etc.})
public class SimpleTestSuite {}

I tried to define a rule which would increase the total number of errors when a test fails, but apparently my rule is never called.

@Rule
public MethodRule logWatchRule = new TestWatchman() {
    public void failed(Throwable e, FrameworkMethod method) {
         errors += 1;
    }

    public void succeeded(FrameworkMethod method) {
    }
};

Any ideas on what I should to do to achieve this behaviour?

© Stack Overflow or respective owner

Related posts about java

Related posts about unit-testing