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

lv.ctco.cukesrest.internal.CucumberFacade Maven / Gradle / Ivy

The newest version!
package lv.ctco.cukesrest.internal;

import com.google.inject.*;
import lv.ctco.cukesrest.*;
import lv.ctco.cukesrest.internal.context.*;

import java.util.*;

@Singleton
public class CucumberFacade {

    /* Ugly Hack proposed by Cucumber developers: https://github.com/cucumber/cucumber-jvm/pull/295 */
    private static boolean firstRun = true;

    @Inject
    GlobalWorldFacade world;

    @Inject
    Set pluginSet;

    @Inject
    RequestSpecificationFacade requestSpecificationFacade;

    public boolean firstScenario() {
        return firstRun;
    }

    public void beforeAllTests() {
        firstRun = false;
        for (CukesRestPlugin cukesRestPlugin : pluginSet) {
            cukesRestPlugin.beforeAllTests();
        }
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                afterAllTests();
            }
        });
    }

    public void beforeScenario() {
        world.reconstruct();
        for (CukesRestPlugin cukesRestPlugin : pluginSet) {
            cukesRestPlugin.beforeScenario();
        }
    }

    public void afterScenario() {
        for (CukesRestPlugin cukesRestPlugin : pluginSet) {
            cukesRestPlugin.afterScenario();
        }
        requestSpecificationFacade.initNewSpecification();
    }

    public void afterAllTests() {
        for (CukesRestPlugin cukesRestPlugin : pluginSet) {
            cukesRestPlugin.afterAllTests();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy