diff --git a/CHANGELOG.md b/CHANGELOG.md index 2717570..542025e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Back to [Readme](README.md). +## [1.7.2] - 2020-04-03 + +### Fixed + +* Cucable does not fail on empty Cucumber feature list file. + ## [1.7.1] - 2020-04-03 ### Changed @@ -298,6 +304,8 @@ Back to [Readme](README.md). Initial project version on GitHub and Maven Central. +[1.7.2]: https://github.com/trivago/cucable-plugin/compare/1.7.1...1.7.2 +[1.7.1]: https://github.com/trivago/cucable-plugin/compare/1.7.0...1.7.1 [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 diff --git a/example-project/pom.xml b/example-project/pom.xml index fe41286..f157d70 100644 --- a/example-project/pom.xml +++ b/example-project/pom.xml @@ -7,7 +7,7 @@ com.trivago.rta cucable-test-project - 1.7.1 + 1.7.2 jar @@ -70,7 +70,7 @@ - + @src/test/resources/cucumber-feature-list.txt diff --git a/plugin-code/pom.xml b/plugin-code/pom.xml index 8f0a3bb..b5c4738 100644 --- a/plugin-code/pom.xml +++ b/plugin-code/pom.xml @@ -6,7 +6,7 @@ com.trivago.rta cucable-plugin - 1.7.1 + 1.7.2 https://github.com/trivago/cucable-plugin Cucable Maven Plugin 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 34eee38..c059c9f 100644 --- a/plugin-code/src/main/java/com/trivago/files/FileSystemManager.java +++ b/plugin-code/src/main/java/com/trivago/files/FileSystemManager.java @@ -60,16 +60,23 @@ public List getPathsFromCucableFeature(final CucableFeature cucableFeature replace("file://", ""); File sourceFeaturesFile = new File(sourceFeatures); + + if (sourceFeatures.trim().isEmpty()) { + return Collections.emptyList(); + } + // 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)); - } else if (sourceFeaturesFile.isDirectory()) { + } + + if (sourceFeaturesFile.isDirectory()) { return getFilesWithFeatureExtension(sourceFeatures); - } else { - throw new CucablePluginException( - sourceFeatures + " is not a feature file or a directory." - ); } + + throw new CucablePluginException( + sourceFeatures + " is not a feature file or a directory." + ); } /** @@ -79,7 +86,8 @@ public List getPathsFromCucableFeature(final CucableFeature cucableFeature * @return A list of feature files in the given directory. * @throws CucablePluginException see {@link CucablePluginException}. */ - private List getFilesWithFeatureExtension(final String sourceFeatureDirectory) throws CucablePluginException { + private List getFilesWithFeatureExtension(final String sourceFeatureDirectory) throws + CucablePluginException { try { return Files.walk(Paths.get(sourceFeatureDirectory)) .filter(Files::isRegularFile) 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 2937132..c96ae25 100644 --- a/plugin-code/src/main/java/com/trivago/properties/PropertyManager.java +++ b/plugin-code/src/main/java/com/trivago/properties/PropertyManager.java @@ -56,7 +56,7 @@ public class PropertyManager { private int desiredNumberOfRunners; private int desiredNumberOfFeaturesPerRunner; private List scenarioNames = new ArrayList<>(); - private boolean isCucumberFeatureListFileSource; + private String cucumberFeatureListFile; @Inject public PropertyManager(final CucableLogger logger, final FileIO fileIO) { @@ -87,8 +87,8 @@ public List getSourceFeatures() { public void setSourceFeatures(final String sourceFeatures) throws MissingFileException { String featuresToProcess; if (sourceFeatures.startsWith("@")) { - isCucumberFeatureListFileSource = true; - featuresToProcess = fileIO.readContentFromFile(sourceFeatures.substring(1)) + cucumberFeatureListFile = sourceFeatures.substring(1); + featuresToProcess = fileIO.readContentFromFile(cucumberFeatureListFile) .replace(System.lineSeparator(), ","); } else { featuresToProcess = sourceFeatures; @@ -256,7 +256,11 @@ public void checkForDisallowedPropertyCombinations() throws CucablePluginExcepti public void logProperties() { CucableLogLevel[] logLevels = new CucableLogLevel[]{DEFAULT, COMPACT}; - logger.info("- sourceFeatures :", logLevels); + if (!isCucumberFeatureListFileSource()) { + logger.info("- sourceFeatures:", logLevels); + } else { + logger.info(String.format("- sourceFeatures from file %s:", cucumberFeatureListFile), logLevels); + } if (sourceFeatures != null) { for (CucableFeature sourceFeature : sourceFeatures) { String logLine = " - " + sourceFeature.getName(); @@ -319,7 +323,7 @@ private void saveMissingProperty( } public boolean isCucumberFeatureListFileSource() { - return isCucumberFeatureListFileSource; + return cucumberFeatureListFile != null && !cucumberFeatureListFile.isEmpty(); } public enum ParallelizationMode { 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 6759584..640521a 100644 --- a/plugin-code/src/test/java/com/trivago/properties/PropertyManagerTest.java +++ b/plugin-code/src/test/java/com/trivago/properties/PropertyManagerTest.java @@ -221,7 +221,7 @@ public void logMandatoryPropertiesTest() throws CucablePluginException { propertyManager.logProperties(); verify(logger, times(6)).info(logCaptor.capture(), any(CucableLogger.CucableLogLevel.class), any(CucableLogger.CucableLogLevel.class)); List capturedLogs = logCaptor.getAllValues(); - assertThat(capturedLogs.get(0), is("- sourceFeatures :")); + assertThat(capturedLogs.get(0), is("- sourceFeatures:")); assertThat(capturedLogs.get(1), is("- sourceRunnerTemplateFile : null")); assertThat(capturedLogs.get(2), is("- generatedRunnerDirectory : null")); assertThat(capturedLogs.get(3), is("- generatedFeatureDirectory : null")); @@ -247,7 +247,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(0), is("- sourceFeatures:")); assertThat(capturedLogs.get(1), is(" - test.feature (line 3)")); assertThat(capturedLogs.get(2), is("- sourceRunnerTemplateFile : null")); assertThat(capturedLogs.get(3), is("- generatedRunnerDirectory : null"));