简体   繁体   中英

testSuccess method implementation for RunListener interface

I have a class that extends RunListener interface (JUnit framework) so i will be able to perform different action depending on the test result. My issue is that the interface has no testSuccess method. (for example the ITestListener from TEstNG framework has a onTestSuccess method) Should i create my own testSuccess method in the class extending RunListener or what can i do?

thank you

RunListener class http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html Example of implementation https://memorynotfound.com/add-junit-listener-example/

i expected that the RunListener interface will have a testSuccess method but it doesn't.

private static final Description FAILED = Description.createTestDescription("failed", "failed");

public void testFinished(Description description) throws Exception {
        System.out.println("Finished test: " + description.getMethodName());
        if (description.getChildren().contains(FAILED)) {
            // action for test failed
        } else {
            // action for test success 
        }
    }

    public void testFailure(Failure failure) throws Exception {
        System.out.println("Failed test: " + failure.getDescription().getMethodName());

// mark the test as being failed 
        failure.getDescription().addChild(FAILED);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM