![JAR search and dependency download from the Maven repository](/logo.png)
com.tngtech.jgiven.spock.junit.JGivenSpockMethodRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jgiven-spock2 Show documentation
Show all versions of jgiven-spock2 Show documentation
Module for writing JGiven tests with Spock 2
The newest version!
package com.tngtech.jgiven.spock.junit;
import com.tngtech.jgiven.impl.ScenarioBase;
import com.tngtech.jgiven.junit.JGivenMethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import spock.lang.Specification;
/**
* JUnit Rule to enable JGiven with Spock2
*
* @since 1.2.0
*/
public class JGivenSpockMethodRule extends JGivenMethodRule {
/**
* @since 1.2.0
*/
public JGivenSpockMethodRule(ScenarioBase scenario) {
super(scenario);
}
@Override
protected void starting(Statement base, FrameworkMethod testMethod, Object target) {
super.starting(base, testMethod, target);
scenario.getScenarioModel().setDescription(methodNameFromSpec(target));
}
private String methodNameFromSpec(Object target) {
return ((Specification) target).getSpecificationContext().getCurrentIteration().getParent().getDisplayName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy