org.pitest.cucumber.CucumberJUnitCompatibleConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pitest-cucumber-plugin Show documentation
Show all versions of pitest-cucumber-plugin Show documentation
Cucumber PIT integration plugin
The newest version!
package org.pitest.cucumber;
import org.pitest.junit.CompoundTestUnitFinder;
import org.pitest.junit.JUnitCompatibleConfiguration;
import org.pitest.testapi.TestGroupConfig;
import org.pitest.testapi.TestUnitFinder;
import org.pitest.util.Log;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
public class CucumberJUnitCompatibleConfiguration extends JUnitCompatibleConfiguration {
public CucumberJUnitCompatibleConfiguration(TestGroupConfig config) {
super(config, Collections.emptyList(), Collections.emptyList());
}
@Override
public TestUnitFinder testUnitFinder() {
final TestUnitFinder finder;
if (isCucumberUsed()) {
Log.getLogger().fine("Cucumber detected, scenarios will be used");
List finders = asList(new CucumberTestUnitFinder(), super.testUnitFinder());
finder = new CompoundTestUnitFinder(finders);
} else {
Log.getLogger().fine("Cucumber not used in this project");
finder = super.testUnitFinder();
}
return finder;
}
private boolean isCucumberUsed() {
boolean result = false;
try {
Class.forName("io.cucumber.junit.Cucumber");
result = true;
} catch (ClassNotFoundException e) {
}
return result;
}
}