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

io.cucumber.testng.TestCaseResultObserver Maven / Gradle / Ivy

There is a newer version: 7.20.1
Show newest version
package io.cucumber.testng;

import io.cucumber.core.eventbus.EventBus;
import io.cucumber.plugin.event.EventPublisher;
import org.testng.SkipException;

import java.util.function.Function;

class TestCaseResultObserver implements AutoCloseable {

    private static final String SKIP_MESSAGE = "This scenario is skipped";
    private final io.cucumber.core.runtime.TestCaseResultObserver delegate;

    private TestCaseResultObserver(EventPublisher bus) {
        this.delegate = new io.cucumber.core.runtime.TestCaseResultObserver(bus);
    }

    static TestCaseResultObserver observe(EventBus bus) {
        return new TestCaseResultObserver(bus);
    }

    void assertTestCasePassed() {
        delegate.assertTestCasePassed(
            () -> new SkipException(SKIP_MESSAGE),
            (exception) -> exception instanceof SkipException
                    ? exception
                    : new SkipException(exception.getMessage(), exception),
            UndefinedStepException::new,
            Function.identity());
    }

    @Override
    public void close() {
        delegate.close();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy