com.github.timm.cucumber.generate.name.PatternNamingScheme Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber-jvm-parallel-plugin Show documentation
Show all versions of cucumber-jvm-parallel-plugin Show documentation
Plugin for assisting with running Cucumber-JVM features in parallel
package com.github.timm.cucumber.generate.name;
/**
* Generate a Class Name based on a pattern.
*
*
* No validation is performed to ensure that the generated class name is valid.
*
*
*
* The following placeholders are supported:
*
*
* - '{f}' - The feature file, converted using supplied naming scheem.
* - '{c}' - A one-up number, formatted to have minimum 2 character width.
*
*/
public class PatternNamingScheme implements ClassNamingScheme {
private final String pattern;
private final Counter counter;
private final ClassNamingScheme featureFileNamingScheme;
/**
* @param pattern The pattern to use.
* @param counter Counter to generate one up numbers
* @param featureFileNamingScheme Naming scheme to use for '{f}' placeholder
*/
public PatternNamingScheme(final String pattern, final Counter counter,
final ClassNamingScheme featureFileNamingScheme) {
this.pattern = pattern;
this.counter = counter;
this.featureFileNamingScheme = featureFileNamingScheme;
}
/**
* @param featureFileName The feature file to generate a class name for
* @return A class name based on the required pattern.
*/
public String generate(final String featureFileName) {
String className =
pattern.replace("{f}", featureFileNamingScheme.generate(featureFileName));
className = className.replace("{c}", String.format("%02d", counter.next()));
return className;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy