All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mill.testng.ResultEvent Maven / Gradle / Ivy

There is a newer version: 0.2.6-14-d4de5f
Show newest version

package mill.testng;

import sbt.testing.*;
import org.testng.ITestResult;

public class ResultEvent {
    static Event failure(ITestResult result){ return event(Status.Failure, result); }
    static Event skipped(ITestResult result){ return event(Status.Skipped, result); }
    static Event success(ITestResult result){ return event(Status.Success, result); }

    static Event event(Status result, ITestResult testNGResult) {
        return new Event() {
            public String fullyQualifiedName() {
                return testNGResult.getTestClass().getName();
            }

            public Fingerprint fingerprint() {
                return TestNGFingerprint.instance;
            }

            public Selector selector() {
                return new SuiteSelector();
            }

            public Status status() {
                return result;
            }

            public OptionalThrowable throwable() {
                if (result != Status.Success){
                    return new OptionalThrowable(testNGResult.getThrowable());
                }else {
                    return new OptionalThrowable();
                }
            }

            @Override
            public long duration() {
                return testNGResult.getEndMillis() - testNGResult.getStartMillis();
            }
        };
    }
    static String classNameOf(ITestResult result){ return result.getTestClass().getName(); }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy