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

com.tngtech.jgiven.base.ScenarioTestBase Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
package com.tngtech.jgiven.base;

import com.google.common.reflect.TypeToken;
import com.tngtech.jgiven.impl.Scenario;
import com.tngtech.jgiven.impl.ScenarioBase;
import com.tngtech.jgiven.integration.CanWire;

import java.util.concurrent.Callable;

/**
 * Base class for Scenario tests.
 * This class is typically not directly used by end users,
 * but instead test-framework-specific classes for JUnit or TestNG
 */
public abstract class ScenarioTestBase {

    @SuppressWarnings( { "serial", "unchecked" } )
    protected Scenario createScenario() {
        Class givenClass = (Class) new TypeToken( getClass() ) {}.getRawType();
        Class whenClass = (Class) new TypeToken( getClass() ) {}.getRawType();
        Class thenClass = (Class) new TypeToken( getClass() ) {}.getRawType();

        return new Scenario( givenClass, whenClass, thenClass );
    }

    public GIVEN given() {
        return getScenario().given();
    }

    public WHEN when() {
        return getScenario().when();
    }

    public THEN then() {
        return getScenario().then();
    }

    /**
     * Adds a new section to the scenario
     * 

EXPERIMENTAL FEATURE

* This is an experimental feature. It might change in the future. * If you have any feedback regarding this feature, please let us know * by creating an issue at https://github.com/TNG/JGiven/issues * @param sectionTitle the title of the section * @since 0.11.0 */ public void section( String sectionTitle ) { getScenario().section( sectionTitle ); } public void wireSteps( CanWire canWire ) { getScenario().wireSteps( canWire ); } /** * Add a new stage class to the scenario. * @param stageClass the class with the step definitions * @return a new instance of the given class enhanced by JGiven */ public T addStage( Class stageClass ) { return getScenario().addStage( stageClass ); } /** * @return the scenario associated with this test */ public abstract Scenario getScenario(); public Scenario createNewScenario() { return createScenario(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy