
net.masterthought.cucumber.Configuration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber-reporting Show documentation
Show all versions of cucumber-reporting Show documentation
Provides pretty html reports for Cucumber (Behaviour-Driven Development). It works by generating html from the
cucumber json report formatter. So can be used anywhere a json report is generated. Current use is in the
cucumber jenkins plugin and a maven mojo to generate the same report from mvn command line when running locally.
package net.masterthought.cucumber;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public class Configuration {
private static final String EMBEDDINGS_DIRECTORY = "embeddings";
private boolean parallelTesting;
private boolean runWithJenkins;
private File reportDirectory;
private File trendsFile;
private int trendsLimit;
private String buildNumber;
private String projectName;
private Collection tagsToExcludeFromChart = new ArrayList<>();
public Configuration(File reportOutputDirectory, String projectName) {
this.reportDirectory = reportOutputDirectory;
this.projectName = projectName;
}
public boolean isParallelTesting() {
return parallelTesting;
}
public void setParallelTesting(boolean parallelTesting) {
this.parallelTesting = parallelTesting;
}
public boolean isRunWithJenkins() {
return runWithJenkins;
}
public void setRunWithJenkins(boolean runWithJenkins) {
this.runWithJenkins = runWithJenkins;
}
public File getReportDirectory() {
return reportDirectory;
}
public File getTrendsStatsFile() {
return trendsFile;
}
/**
* Calls {@link }#setTrends(File, int)} with zero limit.
*/
public void setTrendsStatsFile(File trendsFile) {
setTrends(trendsFile, 0);
}
public int getTrendsLimit() {
return trendsLimit;
}
/**
* Sets configuration for trends. When the limit is set to 0 then all items will be displayed.
*
* @param trendsFile file where information about previous builds is stored
* @param trendsLimit number of builds that should be presented (older builds are skipped)
*/
public void setTrends(File trendsFile, int trendsLimit) {
this.trendsFile = trendsFile;
this.trendsLimit = trendsLimit;
}
public String getBuildNumber() {
return buildNumber;
}
public void setBuildNumber(String buildNumber) {
this.buildNumber = buildNumber;
}
public String getProjectName() {
return projectName;
}
public File getEmbeddingDirectory() {
return new File(getReportDirectory().getAbsolutePath(), ReportBuilder.BASE_DIRECTORY
+ File.separatorChar + Configuration.EMBEDDINGS_DIRECTORY);
}
/**
* @return Patterns to be used to filter out tags in the 'Tags Overview' chart. Returns an empty list by default.
*/
public Collection getTagsToExcludeFromChart() {
return tagsToExcludeFromChart;
}
/**
* Stores the regex patterns to be used for filtering out tags from the 'Tags Overview' chart
*
* @param patterns Regex patterns to match against tags
* @throws ValidationException when any of the given strings is not a valid regex pattern.
*/
public void setTagsToExcludeFromChart(String... patterns) throws ValidationException {
for (String pattern : patterns) {
try {
tagsToExcludeFromChart.add(Pattern.compile(pattern));
} catch (PatternSyntaxException e) {
throw new ValidationException(e);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy