com.tngtech.jgiven.base.DualScenarioTestBase Maven / Gradle / Ivy
package com.tngtech.jgiven.base;
import com.google.common.reflect.TypeToken;
import com.tngtech.jgiven.impl.Scenario;
/**
* ScenarioTest that only takes two type parameters, where the first is used for combined
* GIVEN and WHEN and the second is used for THEN.
*
* This is useful for tests, where you often need to use WHEN steps also in GIVEN statements.
*
* This class is typically not directly used by end users,
* but instead test-framework-specific classes for JUnit or TestNG
*/
public abstract class DualScenarioTestBase extends ScenarioTestBase {
@SuppressWarnings( { "serial", "unchecked" } )
protected Scenario createScenario() {
Class givenWhenClass = (Class) new TypeToken( getClass() ) {}.getRawType();
Class thenClass = (Class) new TypeToken( getClass() ) {}.getRawType();
return new Scenario<>(givenWhenClass, givenWhenClass, thenClass);
}
}