Skip to content

Commit

Permalink
Merge pull request #28 from trivago/0.0.9
Browse files Browse the repository at this point in the history
0.0.9
  • Loading branch information
Benjamin Bischoff authored Oct 27, 2017
2 parents b0d04fa + 577f7df commit 296685a
Show file tree
Hide file tree
Showing 34 changed files with 196 additions and 130 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ Back to [Readme](README.md).
- Ability to generate features and runners in Maven's target folder
- Ability to run multiple features per generated runner

## [0.0.9] - 2017-10-27

### Changed
- Logging is now more compact
- Changed license blocks from trivago GmbH to trivago N.V.

### Added
- It is now possible to process a specific scenario inside a feature file by specifying a line number prefix (like in Cucumber), e.g. ```myFeature.feature:12```.
- More unit tests added.

## [0.0.8] - 2017-09-24

### Changed
Expand Down Expand Up @@ -55,7 +65,8 @@ Back to [Readme](README.md).

Initial project version on GitHub and Maven Central.

[Unreleased]: https://github.com/trivago/cucable-plugin/compare/0.0.8...HEAD
[Unreleased]: https://github.com/trivago/cucable-plugin/compare/0.0.9...HEAD
[0.0.9]: https://github.com/trivago/cucable-plugin/compare/0.0.8...0.0.9
[0.0.8]: https://github.com/trivago/cucable-plugin/compare/0.0.7...0.0.8
[0.0.7]: https://github.com/trivago/cucable-plugin/compare/0.0.6...0.0.7
[0.0.6]: https://github.com/trivago/cucable-plugin/compare/0.0.5...0.0.6
Expand Down
81 changes: 42 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# What is Cucable

Cucable is a Maven plugin for [Cucumber](https://cucumber.io) scenarios that simplifies running scenarios in parallel.
Cucable is a Maven plugin for [Cucumber](https://cucumber.io) scenarios that simplifies parallel test runs.

This plugin has two purposes:

Expand Down Expand Up @@ -134,7 +134,10 @@ public class <b>[FEATURE_FILE_NAME]</b> {

#### (Required) sourceFeatures

The path where your __existing__ Cucumber .feature files are located (e.g. _src/test/resources/features_) _or_ a single .feature file (e.g. src/test/resources/features/MyFeature.feature).
This can specify
* the root path of your __existing__ Cucumber _.feature_ files (e.g. ```src/test/resources/features```)
* the path to a specific __existing__ Cucumber _.feature_ file (e.g. ```src/test/resources/features/MyFeature.feature```)
* the path to a specific __existing__ Cucumber _.feature_ file including the line number of a specific scenario/scenario outline inside this file (e.g. ```src/test/resources/features/MyFeature.feature:12``` would only convert the scenario starting at line _12_ inside _MyFeature.feature_)

__Note:__ This used to be called _sourceFeatureDirectory_ in older versions of Cucable. Since its capabilities changed so it now also supports single features, this was renamed!

Expand Down Expand Up @@ -305,34 +308,35 @@ If all tests should be run regardless of their result, it is important to set ``
However, if this is specified, the build will not fail in case of failing tests! To circumvent that, it is possible to specify a custom Maven fail rule.

```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>Run parallel tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<forkCount>${maven.fork.count}</forkCount>
<reuseForks>false</reuseForks>
<argLine>-Dfile.encoding=UTF-8</argLine>
<disableXmlReport>true</disableXmlReport>
</configuration>
</plugin>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>Run parallel tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<forkCount>${maven.fork.count}</forkCount>
<reuseForks>false</reuseForks>
<argLine>-Dfile.encoding=UTF-8</argLine>
<disableXmlReport>true</disableXmlReport>
</configuration>
</plugin>
</plugins>
```

## 3. Aggregation of a single test report after all test runs
Expand Down Expand Up @@ -379,7 +383,7 @@ Without this rule we would have a successful build every time in case we specify
</dependencies>
<executions>
<execution>
<phase>post-integration-test</phase>
<phase>verify</phase>
<goals>
<goal>enforce</goal>
</goals>
Expand Down Expand Up @@ -442,16 +446,15 @@ So all specified plugins will execute one after the other.
<executions>
<execution>
<id>Run parallel tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<forkCount>${maven.fork.count}</forkCount>
<testFailureIgnore>true</testFailureIgnore>
<reuseForks>false</reuseForks>
<argLine>-Dfile.encoding=UTF-8</argLine>
<disableXmlReport>true</disableXmlReport>
Expand Down Expand Up @@ -488,7 +491,7 @@ So all specified plugins will execute one after the other.
</dependencies>
<executions>
<execution>
<phase>post-integration-test</phase>
<phase>verify</phase>
<goals>
<goal>enforce</goal>
</goals>
Expand Down Expand Up @@ -525,7 +528,7 @@ It is available in [Maven central](https://search.maven.org/#search%7Cgav%7C1%7C

# License

Copyright 2017 trivago GmbH
Copyright 2017 trivago NV

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trivago.rta</groupId>
<artifactId>cucable-plugin</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
<url>https://github.com/trivago/cucable-plugin</url>

<name>Cucable Maven Plugin</name>
Expand All @@ -16,14 +16,14 @@
<inceptionYear>2017</inceptionYear>

<organization>
<name>trivago GmbH</name>
<name>trivago N.V.</name>
<url>http://www.trivago.de</url>
</organization>

<developers>
<developer>
<name>Benjamin Bischoff</name>
<organization>trivago GmbH</organization>
<organization>trivago N.V.</organization>
<organizationUrl>http://www.trivago.de</organizationUrl>
<roles>
<role>Web Test Automation Engineer</role>
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/trivago/rta/CucablePlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@
* The main plugin class.
*/
@Mojo(name = "parallel")
public final class CucablePlugin extends AbstractMojo {
final class CucablePlugin extends AbstractMojo {

private final PropertyManager propertyManager;
private final FileSystemManager fileManager;
Expand Down Expand Up @@ -65,7 +65,7 @@ public final class CucablePlugin extends AbstractMojo {
/**
* An optional number of test runs for each generated .feature file.
*/
@Parameter(property = "parallel.numberOfTestRuns", required = false, defaultValue = "1")
@Parameter(property = "parallel.numberOfTestRuns", defaultValue = "1")
private int numberOfTestRuns = 1;

@Inject
Expand Down Expand Up @@ -98,10 +98,9 @@ public void execute() throws CucablePluginException {
propertyManager.setNumberOfTestRuns(numberOfTestRuns);
propertyManager.validateSettings();

logger.info("╔═════════════════════════════════════╗");
logger.info("║ Cucable Maven Plugin, version " +
getClass().getPackage().getImplementationVersion() + " ║");
logger.info("╚═════════════════════════════════════╝");
logger.info("=====================================");
logger.info(String.format(" Cucable Maven Plugin, version %s", getClass().getPackage().getImplementationVersion()));
logger.info("=====================================");
propertyManager.logProperties();

fileManager.prepareGeneratedFeatureAndRunnerDirs();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
46 changes: 23 additions & 23 deletions src/main/java/com/trivago/rta/features/FeatureFileConverter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,7 +59,6 @@ public final class FeatureFileConverter {
// Holds the current number of single features per feature key
// (in a scenario outline, each example yields a single feature with the same key).
private Map<String, Integer> singleFeatureCounters = new HashMap<>();
private String featureFileName;

@Inject
public FeatureFileConverter(
Expand All @@ -86,18 +85,10 @@ public FeatureFileConverter(
*/
public void convertToSingleScenariosAndRunners(
final List<Path> featureFilePaths) throws CucablePluginException {

logger.info("──────────────────────────────────────");
logger.info("Cucable - starting conversion.");
logger.info("──────────────────────────────────────");

logger.info("");
for (Path featureFilePath : featureFilePaths) {
convertToSingleScenariosAndRunners(featureFilePath);
}

logger.info("──────────────────────────────────────");
logger.info("Cucable - finished conversion.");
logger.info("──────────────────────────────────────");
}

/**
Expand All @@ -112,29 +103,31 @@ public void convertToSingleScenariosAndRunners(
private void convertToSingleScenariosAndRunners(final Path featureFilePath)
throws CucablePluginException {

if (featureFilePath.toString() == null || featureFilePath.toString().equals("")) {
throw new MissingFileException(featureFilePath.toString());
}
String featureFilePathString = featureFilePath.toString();

logger.info(" Converting " + featureFilePath + " ...");
if (featureFilePathString == null || featureFilePathString.equals("")) {
throw new MissingFileException(featureFilePathString);
}

String featureFile = fileIO.readContentFromFile(featureFilePath.toString());
List<SingleScenario> singleScenarios;
Integer lineNumber = propertyManager.getScenarioLineNumber();
String featureFileContent = fileIO.readContentFromFile(featureFilePathString);
List<SingleScenario> singleScenarios = null;
try {
singleScenarios =
gherkinDocumentParser.getSingleScenariosFromFeature(featureFile);
gherkinDocumentParser.getSingleScenariosFromFeature(featureFileContent, lineNumber);
} catch (CucablePluginException e) {
throw new FeatureFileParseException(featureFilePath.toString());
throw new FeatureFileParseException(featureFilePathString);
}

if (propertyManager.hasValidScenarioLineNumber() && singleScenarios.size() == 0) {
throw new CucablePluginException("There is no parseable scenario or scenario outline at line " + lineNumber);
}

for (SingleScenario singleScenario : singleScenarios) {
String renderedFeatureFileContent = featureFileContentRenderer.getRenderedFeatureFileContent(singleScenario);

String featureFileName = getFeatureFileNameFromPath(featureFilePath);

Integer featureCounter = singleFeatureCounters.getOrDefault(featureFileName, 0);
featureCounter++;

String scenarioCounterFilenamePart = String.format(SCENARIO_COUNTER_FORMAT, featureCounter);

for (int testRuns = 1; testRuns <= propertyManager.getNumberOfTestRuns(); testRuns++) {
Expand Down Expand Up @@ -172,8 +165,15 @@ private void convertToSingleScenariosAndRunners(final Path featureFilePath)
fileIO.writeContentToFile(renderedRunnerFileContent, generatedRunnerFilePath);
}
}
logCompleteMessage(featureFilePathString);
}

logger.info(" ↳ Done.");
private void logCompleteMessage(String featureFileName) {
String logPostfix = ".";
if (propertyManager.hasValidScenarioLineNumber()) {
logPostfix = String.format(" with line number %d.", propertyManager.getScenarioLineNumber());
}
logger.info(String.format("- Cucable processed [%s]%s", featureFileName, logPostfix));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/trivago/rta/files/FileIO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 trivago GmbH
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 296685a

Please sign in to comment.