diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0734518..ef92d49 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Back to [Readme](README.md).
+## [1.7.0] - 2020-03-30
+
+### Added
+
+* Support for Cucumber feature text files
+
+### Changed
+
+* Various dependency and documentation updates
+
## [1.6.0] - 2019-12-10
### Changed
@@ -282,6 +292,7 @@ Back to [Readme](README.md).
Initial project version on GitHub and Maven Central.
+[1.7.0]: https://github.com/trivago/cucable-plugin/compare/1.6.0...1.7.0
[1.6.0]: https://github.com/trivago/cucable-plugin/compare/1.5.3...1.6.0
[1.5.3]: https://github.com/trivago/cucable-plugin/compare/1.5.2...1.5.3
[1.5.2]: https://github.com/trivago/cucable-plugin/compare/1.5.1...1.5.2
diff --git a/README.md b/README.md
index a7b9bca..ba3bff6 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
### Note:
-This project is feature-complete. Expect only bug fixes at this time.
+This project is feature-complete. Expect mostly bug fixes from this point on.
For new projects, you should consider using Cucumber's native parallelization feature instead.
Thanks to everyone using, testing and improving Cucable over the last years!
@@ -326,10 +326,30 @@ If you use a text file (e.g. _src/test/resources/cucable.template_), all **[CUCA
#### sourceFeatures
-This can specify
-* the root path of your __existing__ [Cucumber](https://cucumber.io) _.feature_ files (e.g. ```src/test/resources/features```)
-* the path to a specific __existing__ [Cucumber](https://cucumber.io) _.feature_ file (e.g. ```src/test/resources/features/MyFeature.feature```)
-* the path to a specific __existing__ [Cucumber](https://cucumber.io) _.feature_ file including line numbers of specific scenarios/scenario outlines inside this file (e.g. ```src/test/resources/features/MyFeature.feature:12:19``` would only convert the scenarios starting at line _12_ and _19_ inside _MyFeature.feature_)
+This property specifies the location of the features that Cucable should process. It must point to one of the following:
+
+* the root path of your __existing__ [Cucumber](https://cucumber.io) _.feature_ files, e.g.
+ `src/test/resources/features`
+* the path to a specific __existing__ [Cucumber](https://cucumber.io) _.feature_ file, e.g.
+ `src/test/resources/features/MyFeature.feature`
+* the path to a specific __existing__ [Cucumber](https://cucumber.io) _.feature_ file with optional line numbers of specific scenarios e.g.
+ `src/test/resources/features/MyFeature.feature:12:19`
+* comma separated paths to specific __existing__ [Cucumber](https://cucumber.io) _.feature_ file(s) with optional line numbers or feature directories e.g.
+ ```
+ src/test/resources/features/MyFeature.feature:12:19, src/test/resources/features/MyOther.feature, src/test/some/other/feature/directory
+ ```
+* the path to a [Cucumber](https://cucumber.io) text file containing the path to a feature including line number(s) per line (as written by the [Cucumber rerun reporter plugin](https://cucumber.io/docs/cucumber/reporting/?sbsearch=rerun#built-in-reporter-plugins), e.g.
+ ```
+ @src/test/resources/rerun.txt
+ ```
+
+ __Note:__ The path to a text file has to start with an `@` character!
+
+ The file contents can look like this:
+ ```
+ file:///pathToProject/resources/features/feature1.feature:12
+ file:///pathToProject/resources/features/feature4.feature:6
+ ```
**Note:** From Cucable 1.4.0 onwards it is possible to specify a combination as a comma separated list:
diff --git a/example-project/pom.xml b/example-project/pom.xml
index d2a04c0..7a75c56 100644
--- a/example-project/pom.xml
+++ b/example-project/pom.xml
@@ -7,7 +7,7 @@
com.trivago.rta
cucable-test-project
- 1.6.0
+ 1.7.0
jar
@@ -15,7 +15,7 @@
UTF-8
3.0.0-M3
3.0.0
- 4.5.4
+ 5.5.0
3.7.0
3.1.2
@@ -69,6 +69,9 @@
+
+
+
diff --git a/example-project/src/test/java/some/template/CucableJavaTemplate.java b/example-project/src/test/java/some/template/CucableJavaTemplate.java
index 534d6af..26dcdd3 100644
--- a/example-project/src/test/java/some/template/CucableJavaTemplate.java
+++ b/example-project/src/test/java/some/template/CucableJavaTemplate.java
@@ -1,12 +1,13 @@
package some.template;
-import cucumber.api.CucumberOptions;
-import cucumber.api.junit.Cucumber;
+import io.cucumber.junit.Cucumber;
+import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "steps",
+ strict = true,
features = {"target/parallel/features/[CUCABLE:FEATURE].feature"},
plugin = {"json:target/cucumber-report/[CUCABLE:RUNNER].json"}
)
diff --git a/example-project/src/test/java/steps/ExampleSteps.java b/example-project/src/test/java/steps/ExampleSteps.java
index 7cb1175..9e42685 100644
--- a/example-project/src/test/java/steps/ExampleSteps.java
+++ b/example-project/src/test/java/steps/ExampleSteps.java
@@ -1,16 +1,18 @@
package steps;
-import cucumber.api.java.en.And;
-import cucumber.api.java.en.Given;
-import cucumber.api.java.en.Then;
-import cucumber.api.java.en.When;
-import cucumber.api.java.no.Gitt;
-import cucumber.api.java.no.Og;
-import cucumber.api.java.ro.Atunci;
-import cucumber.api.java.ro.Cand;
-import cucumber.api.java.ro.Datefiind;
import io.cucumber.datatable.DataTable;
-
+import io.cucumber.docstring.DocString;
+import io.cucumber.java.en.And;
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
+import io.cucumber.java.no.Gitt;
+import io.cucumber.java.no.Og;
+import io.cucumber.java.ro.Atunci;
+import io.cucumber.java.ro.Cand;
+import io.cucumber.java.ro.Datefiind;
+
+@SuppressWarnings("unused")
public class ExampleSteps {
@Given("^this is a given step$")
public void thisIsAGivenStep() {
@@ -49,11 +51,11 @@ public void thisIsABackgroundStep() {
}
@Given("^this is a given step with a docstring$")
- public void thisIsAGivenStepWithADocstring(DataTable docString) {
+ public void thisIsAGivenStepWithADocstring(DocString docString) {
}
@Then("^I do something with a docstring$")
- public void iDoSomethingWithADocstring(DataTable docString) {
+ public void iDoSomethingWithADocstring(DocString docString) {
}
@Gitt("^for å unngå at firmaet går konkurs$")
diff --git a/example-project/src/test/resources/cucable.template b/example-project/src/test/resources/cucable.template
index 80fe4f6..5d989fd 100644
--- a/example-project/src/test/resources/cucable.template
+++ b/example-project/src/test/resources/cucable.template
@@ -1,12 +1,14 @@
-import cucumber.api.CucumberOptions;
+import io.cucumber.junit.Cucumber;
+import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "steps",
+ strict = true,
features = {"target/parallel/features/[CUCABLE:FEATURE].feature"},
plugin = {"json:target/cucumber-report/[CUCABLE:RUNNER].json"}
)
-public class [CUCABLE:RUNNER] {
+public class CucableJavaTemplate {
// [CUCABLE:CUSTOM:comment]
}
\ No newline at end of file
diff --git a/example-project/src/test/resources/cucumber-feature-list.txt b/example-project/src/test/resources/cucumber-feature-list.txt
new file mode 100644
index 0000000..f015f15
--- /dev/null
+++ b/example-project/src/test/resources/cucumber-feature-list.txt
@@ -0,0 +1,3 @@
+src/test/resources/features/testfeature/MyTest1.feature:12
+src/test/resources/features/testfeature/MyTest1.feature:19
+src/test/resources/features/testfeature/MyTest4.feature:5
\ No newline at end of file
diff --git a/plugin-code/pom.xml b/plugin-code/pom.xml
index 29bddf6..e322e47 100644
--- a/plugin-code/pom.xml
+++ b/plugin-code/pom.xml
@@ -6,7 +6,7 @@
com.trivago.rta
cucable-plugin
- 1.6.0
+ 1.7.0
https://github.com/trivago/cucable-plugin
Cucable Maven Plugin
@@ -63,7 +63,7 @@
UTF-8
- 3.6.1
+ 3.6.3
1.6
1.6.8
3.5.1
@@ -71,17 +71,17 @@
3.7.0
3.3.0
0.8.4
- 2.0.0
+ 2.1.0
3.6.0
3.0.1
1.8
1.8
- 5.1.0
- 2.0.2
- 3.9
+ 5.2.0
+ 2.0.4
+ 3.10
- 3.2.0
- 5.6.0-M1
+ 3.3.3
+ 5.6.1
0.8.13
diff --git a/plugin-code/src/main/java/com/trivago/CucablePlugin.java b/plugin-code/src/main/java/com/trivago/CucablePlugin.java
index 6f7c4ce..b35e2db 100644
--- a/plugin-code/src/main/java/com/trivago/CucablePlugin.java
+++ b/plugin-code/src/main/java/com/trivago/CucablePlugin.java
@@ -31,7 +31,7 @@
/**
* The main plugin class.
*/
-@SuppressWarnings("FieldCanBeLocal")
+@SuppressWarnings("unused")
@Mojo(name = "parallel")
final class
CucablePlugin extends AbstractMojo {
@@ -44,25 +44,25 @@
/**
* The complete path to the runner template file.
*/
- @Parameter(property = "parallel.sourceRunnerTemplateFile", required = true, defaultValue = "")
+ @Parameter(property = "parallel.sourceRunnerTemplateFile", required = true)
private String sourceRunnerTemplateFile;
/**
* The path where the generated runner classes should be created.
*/
- @Parameter(property = "parallel.generatedRunnerDirectory", required = true, defaultValue = "")
+ @Parameter(property = "parallel.generatedRunnerDirectory", required = true)
private String generatedRunnerDirectory;
/**
* The path to .feature files or a concrete single feature file.
*/
- @Parameter(property = "parallel.sourceFeatures", required = true, defaultValue = "")
+ @Parameter(property = "parallel.sourceFeatures", required = true)
private String sourceFeatures;
/**
* The path where the generated .feature files should be created.
*/
- @Parameter(property = "parallel.generatedFeatureDirectory", required = true, defaultValue = "")
+ @Parameter(property = "parallel.generatedFeatureDirectory", required = true)
private String generatedFeatureDirectory;
/**
diff --git a/plugin-code/src/main/java/com/trivago/features/FeatureFileConverter.java b/plugin-code/src/main/java/com/trivago/features/FeatureFileConverter.java
index 8f4aaea..f7cbd96 100644
--- a/plugin-code/src/main/java/com/trivago/features/FeatureFileConverter.java
+++ b/plugin-code/src/main/java/com/trivago/features/FeatureFileConverter.java
@@ -67,7 +67,7 @@ public class FeatureFileConverter {
private final FeatureFileContentRenderer featureFileContentRenderer;
private final RunnerFileContentRenderer runnerFileContentRenderer;
private final FileIO fileIO;
- private FileSystemManager fileSystemManager;
+ private final FileSystemManager fileSystemManager;
private final CucableLogger logger;
// Holds the current number of single features per feature key
@@ -107,6 +107,9 @@ public void generateParallelizableFeatures(
for (CucableFeature cucableFeature : cucableFeatures) {
List paths = fileSystemManager.getPathsFromCucableFeature(cucableFeature);
+ if (paths.size() == 0) {
+ logger.warn("No features and runners could be created. Please check your properties!");
+ }
for (Path path : paths) {
List generatedFeatureFilePaths = generateParallelizableFeatures(path, cucableFeature.getLineNumbers());
allGeneratedFeaturePaths.addAll(generatedFeatureFilePaths);
diff --git a/plugin-code/src/main/java/com/trivago/files/FileSystemManager.java b/plugin-code/src/main/java/com/trivago/files/FileSystemManager.java
index dab26e3..34eee38 100644
--- a/plugin-code/src/main/java/com/trivago/files/FileSystemManager.java
+++ b/plugin-code/src/main/java/com/trivago/files/FileSystemManager.java
@@ -52,12 +52,14 @@ public FileSystemManager(PropertyManager propertyManager) {
*/
public List getPathsFromCucableFeature(final CucableFeature cucableFeature) throws CucablePluginException {
- if (cucableFeature == null){
+ if (cucableFeature == null) {
return Collections.emptyList();
}
- String sourceFeatures = cucableFeature.getName();
- File sourceFeaturesFile = new File(cucableFeature.getName());
+ String sourceFeatures = cucableFeature.getName().
+ replace("file://", "");
+
+ File sourceFeaturesFile = new File(sourceFeatures);
// Check if the property value is a single file or a directory
if (sourceFeaturesFile.isFile() && sourceFeatures.endsWith(FEATURE_FILE_EXTENSION)) {
return Collections.singletonList(Paths.get(sourceFeatures));
diff --git a/plugin-code/src/main/java/com/trivago/gherkin/GherkinTranslations.java b/plugin-code/src/main/java/com/trivago/gherkin/GherkinTranslations.java
index 90e532d..7d55251 100644
--- a/plugin-code/src/main/java/com/trivago/gherkin/GherkinTranslations.java
+++ b/plugin-code/src/main/java/com/trivago/gherkin/GherkinTranslations.java
@@ -5,8 +5,6 @@
import javax.inject.Inject;
import javax.inject.Singleton;
-import java.util.Arrays;
-import java.util.List;
@Singleton
class GherkinTranslations {
diff --git a/plugin-code/src/main/java/com/trivago/properties/PropertyManager.java b/plugin-code/src/main/java/com/trivago/properties/PropertyManager.java
index 14e9967..6e50bd1 100644
--- a/plugin-code/src/main/java/com/trivago/properties/PropertyManager.java
+++ b/plugin-code/src/main/java/com/trivago/properties/PropertyManager.java
@@ -17,7 +17,9 @@
package com.trivago.properties;
import com.trivago.exceptions.CucablePluginException;
+import com.trivago.exceptions.filesystem.MissingFileException;
import com.trivago.exceptions.properties.WrongOrMissingPropertiesException;
+import com.trivago.files.FileIO;
import com.trivago.logging.CucableLogger;
import com.trivago.logging.CucableLogger.CucableLogLevel;
import com.trivago.logging.Language;
@@ -41,6 +43,7 @@
public class PropertyManager {
private final CucableLogger logger;
+ private final FileIO fileIO;
private String sourceRunnerTemplateFile;
private String generatedRunnerDirectory;
@@ -55,8 +58,9 @@ public class PropertyManager {
private List scenarioNames = new ArrayList<>();
@Inject
- public PropertyManager(CucableLogger logger) {
+ public PropertyManager(final CucableLogger logger, final FileIO fileIO) {
this.logger = logger;
+ this.fileIO = fileIO;
}
public String getSourceRunnerTemplateFile() {
@@ -79,10 +83,21 @@ public List getSourceFeatures() {
return sourceFeatures;
}
- public void setSourceFeatures(final String sourceFeatures) {
+ public void setSourceFeatures(final String sourceFeatures) throws MissingFileException {
+ String featuresToProcess;
+ if (sourceFeatures.startsWith("@")) {
+ featuresToProcess = fileIO.readContentFromFile(sourceFeatures.substring(1))
+ .replace("\n", ",");
+ } else {
+ featuresToProcess = sourceFeatures;
+ }
+ this.sourceFeatures = sourceFeaturePathsToCucableFeatureList(featuresToProcess.split(","));
+ }
+
+ private List sourceFeaturePathsToCucableFeatureList(final String[] sourceFeatures) {
List cucableFeatures = new ArrayList<>();
Pattern lineNumberPattern = Pattern.compile(":(\\d*)");
- for (String sourceFeature : sourceFeatures.split(",")) {
+ for (String sourceFeature : sourceFeatures) {
String trimmedFeature = sourceFeature.trim();
StringBuffer resultBuffer = new StringBuffer();
Matcher matcher = lineNumberPattern.matcher(trimmedFeature);
@@ -98,8 +113,7 @@ public void setSourceFeatures(final String sourceFeatures) {
matcher.appendTail(resultBuffer);
cucableFeatures.add(new CucableFeature(resultBuffer.toString(), scenarioLineNumbers));
}
-
- this.sourceFeatures = cucableFeatures;
+ return cucableFeatures;
}
public String getGeneratedFeatureDirectory() {
@@ -246,8 +260,8 @@ public void logProperties() {
String logLine = " - " + sourceFeature.getName();
if (sourceFeature.hasValidScenarioLineNumbers()) {
List lineNumbers = sourceFeature.getLineNumbers();
- logLine += String.format(" with %s %s",
- Language.singularPlural(lineNumbers.size(), "line number", "line numbers"),
+ logLine += String.format(" (%s %s)",
+ Language.singularPlural(lineNumbers.size(), "line", "lines"),
lineNumbers.stream().map(String::valueOf).collect(Collectors.joining(",")));
}
logger.info(logLine, logLevels);
diff --git a/plugin-code/src/main/java/com/trivago/vo/CucableFeature.java b/plugin-code/src/main/java/com/trivago/vo/CucableFeature.java
index 004b452..92d9f6a 100644
--- a/plugin-code/src/main/java/com/trivago/vo/CucableFeature.java
+++ b/plugin-code/src/main/java/com/trivago/vo/CucableFeature.java
@@ -19,8 +19,8 @@
import java.util.List;
public class CucableFeature {
- private String name;
- private List lineNumbers;
+ private final String name;
+ private final List lineNumbers;
public CucableFeature(final String name, final List lineNumbers) {
this.name = name;
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/CucablePluginExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/CucablePluginExceptionTest.java
index b1ebe71..2984e53 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/CucablePluginExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/CucablePluginExceptionTest.java
@@ -19,7 +19,7 @@
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class CucablePluginExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FeatureFileParseExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FeatureFileParseExceptionTest.java
index b806d12..330468c 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FeatureFileParseExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FeatureFileParseExceptionTest.java
@@ -19,7 +19,7 @@
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class FeatureFileParseExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileCreationExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileCreationExceptionTest.java
index 4af6d11..b7f0345 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileCreationExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileCreationExceptionTest.java
@@ -19,7 +19,7 @@
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class FileCreationExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileDeletionExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileDeletionExceptionTest.java
index 94cee41..b77a96d 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileDeletionExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/FileDeletionExceptionTest.java
@@ -19,7 +19,7 @@
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class FileDeletionExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/MissingFileExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/MissingFileExceptionTest.java
index 333d726..d144f46 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/MissingFileExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/MissingFileExceptionTest.java
@@ -19,7 +19,7 @@
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class MissingFileExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/PathCreationExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/PathCreationExceptionTest.java
index e7a43a6..b3cacdd 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/filesystem/PathCreationExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/filesystem/PathCreationExceptionTest.java
@@ -19,7 +19,7 @@
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class PathCreationExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/exceptions/properties/WrongOrMissingPropertiesExceptionTest.java b/plugin-code/src/test/java/com/trivago/exceptions/properties/WrongOrMissingPropertiesExceptionTest.java
index d6f4e1c..253d881 100644
--- a/plugin-code/src/test/java/com/trivago/exceptions/properties/WrongOrMissingPropertiesExceptionTest.java
+++ b/plugin-code/src/test/java/com/trivago/exceptions/properties/WrongOrMissingPropertiesExceptionTest.java
@@ -22,7 +22,7 @@
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class WrongOrMissingPropertiesExceptionTest {
diff --git a/plugin-code/src/test/java/com/trivago/features/FeatureFileContentRendererTest.java b/plugin-code/src/test/java/com/trivago/features/FeatureFileContentRendererTest.java
index 3d62dc5..8428040 100644
--- a/plugin-code/src/test/java/com/trivago/features/FeatureFileContentRendererTest.java
+++ b/plugin-code/src/test/java/com/trivago/features/FeatureFileContentRendererTest.java
@@ -11,8 +11,8 @@
import java.util.Collections;
import java.util.List;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
public class FeatureFileContentRendererTest {
diff --git a/plugin-code/src/test/java/com/trivago/features/FeatureFileConverterTest.java b/plugin-code/src/test/java/com/trivago/features/FeatureFileConverterTest.java
index 9706f70..55b3ea4 100644
--- a/plugin-code/src/test/java/com/trivago/features/FeatureFileConverterTest.java
+++ b/plugin-code/src/test/java/com/trivago/features/FeatureFileConverterTest.java
@@ -1,8 +1,6 @@
package com.trivago.features;
import com.trivago.exceptions.CucablePluginException;
-import com.trivago.exceptions.filesystem.FileCreationException;
-import com.trivago.exceptions.filesystem.MissingFileException;
import com.trivago.files.FileIO;
import com.trivago.files.FileSystemManager;
import com.trivago.gherkin.GherkinDocumentParser;
@@ -25,7 +23,7 @@
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
@@ -51,14 +49,14 @@ public class FeatureFileConverterTest {
private FileSystemManager fileSystemManager;
@Before
- public void setup() throws MissingFileException, FileCreationException {
+ public void setup() {
gherkinDocumentParser = mock(GherkinDocumentParser.class);
featureFileContentRenderer = mock(FeatureFileContentRenderer.class);
runnerFileContentRenderer = mock(RunnerFileContentRenderer.class);
fileIO = mock(FileIO.class);
fileSystemManager = mock(FileSystemManager.class);
logger = mock(CucableLogger.class);
- propertyManager = new PropertyManager(logger);
+ propertyManager = new PropertyManager(logger, fileIO);
featureFileConverter = new FeatureFileConverter(
propertyManager,
diff --git a/plugin-code/src/test/java/com/trivago/files/FileSystemManagerTest.java b/plugin-code/src/test/java/com/trivago/files/FileSystemManagerTest.java
index 37fcc6a..857774b 100644
--- a/plugin-code/src/test/java/com/trivago/files/FileSystemManagerTest.java
+++ b/plugin-code/src/test/java/com/trivago/files/FileSystemManagerTest.java
@@ -14,7 +14,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/plugin-code/src/test/java/com/trivago/gherkin/GherkinDocumentParserTest.java b/plugin-code/src/test/java/com/trivago/gherkin/GherkinDocumentParserTest.java
index 584f6ff..b69dee0 100644
--- a/plugin-code/src/test/java/com/trivago/gherkin/GherkinDocumentParserTest.java
+++ b/plugin-code/src/test/java/com/trivago/gherkin/GherkinDocumentParserTest.java
@@ -14,10 +14,12 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class GherkinDocumentParserTest {
diff --git a/plugin-code/src/test/java/com/trivago/gherkin/GherkinToCucableConverterTest.java b/plugin-code/src/test/java/com/trivago/gherkin/GherkinToCucableConverterTest.java
index 636bfd0..8b45749 100644
--- a/plugin-code/src/test/java/com/trivago/gherkin/GherkinToCucableConverterTest.java
+++ b/plugin-code/src/test/java/com/trivago/gherkin/GherkinToCucableConverterTest.java
@@ -15,7 +15,7 @@
import java.util.Map;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class GherkinToCucableConverterTest {
private GherkinToCucableConverter gherkinToCucableConverter;
diff --git a/plugin-code/src/test/java/com/trivago/gherkin/GherkinTranslationsTest.java b/plugin-code/src/test/java/com/trivago/gherkin/GherkinTranslationsTest.java
index 72aebf1..d2018fa 100644
--- a/plugin-code/src/test/java/com/trivago/gherkin/GherkinTranslationsTest.java
+++ b/plugin-code/src/test/java/com/trivago/gherkin/GherkinTranslationsTest.java
@@ -4,7 +4,7 @@
import org.junit.Test;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class GherkinTranslationsTest {
private GherkinTranslations gherkinTranslations;
diff --git a/plugin-code/src/test/java/com/trivago/properties/PropertyManagerTest.java b/plugin-code/src/test/java/com/trivago/properties/PropertyManagerTest.java
index 6d159bd..6759584 100644
--- a/plugin-code/src/test/java/com/trivago/properties/PropertyManagerTest.java
+++ b/plugin-code/src/test/java/com/trivago/properties/PropertyManagerTest.java
@@ -1,7 +1,9 @@
package com.trivago.properties;
import com.trivago.exceptions.CucablePluginException;
+import com.trivago.exceptions.filesystem.MissingFileException;
import com.trivago.exceptions.properties.WrongOrMissingPropertiesException;
+import com.trivago.files.FileIO;
import com.trivago.logging.CucableLogger;
import com.trivago.vo.CucableFeature;
import org.junit.Before;
@@ -17,12 +19,13 @@
import java.util.Map;
import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class PropertyManagerTest {
@Rule
@@ -31,11 +34,13 @@ public class PropertyManagerTest {
public ExpectedException expectedException = ExpectedException.none();
private PropertyManager propertyManager;
private CucableLogger logger;
+ private FileIO fileIO;
@Before
public void setup() {
logger = mock(CucableLogger.class);
- propertyManager = new PropertyManager(logger);
+ fileIO = mock(FileIO.class);
+ propertyManager = new PropertyManager(logger, fileIO);
}
@Test
@@ -111,7 +116,7 @@ public void wrongParallelizationModeTest() throws CucablePluginException {
}
@Test
- public void featureWithoutScenarioLineNumberTest() {
+ public void featureWithoutScenarioLineNumberTest() throws MissingFileException {
propertyManager.setSourceFeatures("my.feature");
List sourceFeatures = propertyManager.getSourceFeatures();
assertThat(sourceFeatures.size(), is(1));
@@ -121,7 +126,23 @@ public void featureWithoutScenarioLineNumberTest() {
}
@Test
- public void featureWithScenarioLineNumberTest() {
+ public void featureTextFileTest() throws MissingFileException {
+ when(fileIO.readContentFromFile("src/test/resources/features.txt")).thenCallRealMethod();
+ propertyManager.setSourceFeatures("@src/test/resources/features.txt");
+ List sourceFeatures = propertyManager.getSourceFeatures();
+ assertThat(sourceFeatures.size(), is(2));
+ assertThat(sourceFeatures.get(0).getName(), is("file:///features/feature1.feature"));
+ assertThat(sourceFeatures.get(0).getLineNumbers(), is(notNullValue()));
+ assertThat(sourceFeatures.get(0).getLineNumbers().size(), is(1));
+ assertThat(sourceFeatures.get(0).getLineNumbers().get(0), is(12));
+ assertThat(sourceFeatures.get(1).getName(), is("file:///features/feature2.feature"));
+ assertThat(sourceFeatures.get(1).getLineNumbers(), is(notNullValue()));
+ assertThat(sourceFeatures.get(1).getLineNumbers().size(), is(1));
+ assertThat(sourceFeatures.get(1).getLineNumbers().get(0), is(25));
+ }
+
+ @Test
+ public void featureWithScenarioLineNumberTest() throws MissingFileException {
propertyManager.setSourceFeatures("my.feature:123");
List sourceFeatures = propertyManager.getSourceFeatures();
assertThat(sourceFeatures.size(), is(1));
@@ -131,7 +152,7 @@ public void featureWithScenarioLineNumberTest() {
}
@Test
- public void featureWithInvalidScenarioLineNumberTest() {
+ public void featureWithInvalidScenarioLineNumberTest() throws MissingFileException {
propertyManager.setSourceFeatures("my.feature:abc");
List sourceFeatures = propertyManager.getSourceFeatures();
assertThat(sourceFeatures.size(), is(1));
@@ -227,7 +248,7 @@ public void logExtendedPropertiesTest() throws CucablePluginException {
verify(logger, times(12)).info(logCaptor.capture(), any(CucableLogger.CucableLogLevel.class), any(CucableLogger.CucableLogLevel.class));
List capturedLogs = logCaptor.getAllValues();
assertThat(capturedLogs.get(0), is("- sourceFeatures :"));
- assertThat(capturedLogs.get(1), is(" - test.feature with line number 3"));
+ assertThat(capturedLogs.get(1), is(" - test.feature (line 3)"));
assertThat(capturedLogs.get(2), is("- sourceRunnerTemplateFile : null"));
assertThat(capturedLogs.get(3), is("- generatedRunnerDirectory : null"));
assertThat(capturedLogs.get(4), is("- generatedFeatureDirectory : null"));
diff --git a/plugin-code/src/test/java/com/trivago/runners/RunnerFileContentRendererTest.java b/plugin-code/src/test/java/com/trivago/runners/RunnerFileContentRendererTest.java
index cf25bb3..e0b3033 100644
--- a/plugin-code/src/test/java/com/trivago/runners/RunnerFileContentRendererTest.java
+++ b/plugin-code/src/test/java/com/trivago/runners/RunnerFileContentRendererTest.java
@@ -13,7 +13,7 @@
import java.util.Map;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/plugin-code/src/test/java/com/trivago/vo/DataTableTest.java b/plugin-code/src/test/java/com/trivago/vo/DataTableTest.java
index 84880bf..95be6da 100644
--- a/plugin-code/src/test/java/com/trivago/vo/DataTableTest.java
+++ b/plugin-code/src/test/java/com/trivago/vo/DataTableTest.java
@@ -6,7 +6,7 @@
import java.util.List;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class DataTableTest {
@Test
diff --git a/plugin-code/src/test/resources/features.txt b/plugin-code/src/test/resources/features.txt
new file mode 100644
index 0000000..044b664
--- /dev/null
+++ b/plugin-code/src/test/resources/features.txt
@@ -0,0 +1,2 @@
+file:///features/feature1.feature:12
+file:///features/feature2.feature:25
\ No newline at end of file