Skip to content

Commit

Permalink
Merge pull request #59 from trivago/0.1.8
Browse files Browse the repository at this point in the history
0.1.8
  • Loading branch information
Benjamin Bischoff authored Mar 30, 2018
2 parents 6d21315 + 48f9415 commit 1b331f7
Show file tree
Hide file tree
Showing 31 changed files with 438 additions and 565 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [0.1.8] - 2018-03-30

### Added

- Source feature path is now included as a comment in generated features and runners
- Configurable logging with 4 levels: _default_, _compact_, _minimal_, _off_
- The number of generated scenarios per feature is shown in the default logs
- The total number of generated features is shown in a summary line in all log levels except _off_

### Changed

- All dependencies are updated to their latest version

## [0.1.7] - 2018-03-02

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

Initial project version on GitHub and Maven Central.

[0.1.7]: https://github.com/trivago/cucable-plugin/compare/0.1.5...0.1.7
[0.1.8]: https://github.com/trivago/cucable-plugin/compare/0.1.7...0.1.8
[0.1.7]: https://github.com/trivago/cucable-plugin/compare/0.1.6...0.1.7
[0.1.6]: https://github.com/trivago/cucable-plugin/compare/0.1.5...0.1.6
[0.1.5]: https://github.com/trivago/cucable-plugin/compare/0.1.4...0.1.5
[0.1.4]: https://github.com/trivago/cucable-plugin/compare/0.1.3...0.1.4
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [numberOfTestRuns](#numberoftestruns)
- [includeScenarioTags](#includescenariotags)
- [excludeScenarioTags](#excludescenariotags)
- [logLevel](#loglevel)
- [Generating runners and features inside target directory](#generating-runners-and-features-inside-target-directory)
- [Complete Example](#complete-example)
- [Source feature file](#source-feature-file)
Expand Down Expand Up @@ -115,7 +116,8 @@ The following sections break down the above steps.
</includeScenarioTags>
<excludeScenarioTags>
<param>@skip</param>
</excludeScenarioTags>
</excludeScenarioTags>
<logLevel>compact</logLevel>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -219,6 +221,25 @@ To include multiple tags, just add each one into as its own ```<param>```:
__Note:__ When using _includeScenarioTags_ and _excludeScenarioTags_ together, the _excludeScenarioTags_ will override the _includeScenarioTags_.
This means that a scenario containing an included tag __and__ an excluded tag will be __excluded__!

#### logLevel

By default, Cucable logs all information including

* its own name and version
* all passed property values
* a list of processed feature paths

This can be configured by passing the `logLevel` property:

```
<logLevel>default|compact|minimal|off</logLevel>
```

* _default_ will log all the mentioned information
* _compact_ will only log the plugin name, version, properties and one line of summary
* _minimal_ will only log a summary line
* _off_ will prevent any logging

### Generating runners and features inside target directory

It may be desirable for you to generate the Cucable features and runners in Maven's `target` directory.
Expand Down
19 changes: 13 additions & 6 deletions example-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.benjamin-bischoff</groupId>
<artifactId>cucable-test-project</artifactId>
<version>0.1.7</version>
<version>0.1.8</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -47,18 +47,25 @@
<!--<sourceFeatures>src/test/resources/features/testfeature/MyTest1.feature:8:19</sourceFeatures>-->

<!-- include scenarios with certain tags -->
<includeScenarioTags>
<!--<includeScenarioTags>-->
<!--<param>@scenarioTag1</param>-->
</includeScenarioTags>
<!--<param>@scenarioTag2</param>-->
<!--</includeScenarioTags>-->

<!-- exclude scenarios with certain tags -->
<excludeScenarioTags>
<param>@skipme</param>
</excludeScenarioTags>
<!--<excludeScenarioTags>-->
<!--<param>@skipme</param>-->
<!--</excludeScenarioTags>-->

<generatedFeatureDirectory>${generated.feature.directory}</generatedFeatureDirectory>
<generatedRunnerDirectory>${generated.runner.directory}</generatedRunnerDirectory>
<numberOfTestRuns>1</numberOfTestRuns>

<!-- Logging -->
<logLevel>default</logLevel>
<!--<logLevel>compact</logLevel>-->
<!--<logLevel>minimal</logLevel>-->
<!--<logLevel>off</logLevel>-->
</configuration>
</execution>
</executions>
Expand Down
20 changes: 10 additions & 10 deletions plugin-code/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.1.7</version>
<version>0.1.8</version>
<url>https://github.com/trivago/cucable-plugin</url>

<name>Cucable Maven Plugin</name>
Expand Down Expand Up @@ -62,26 +62,26 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.version>3.5.2</maven.version>
<maven.version>3.5.3</maven.version>
<maven.compat.version>3.3.9</maven.compat.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<nexus.staging.maven.plugin.version>1.6.8</nexus.staging.maven.plugin.version>
<maven.plugin.plugin.version>3.4</maven.plugin.plugin.version>
<maven.plugin.plugin.version>3.5.1</maven.plugin.plugin.version>
<maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
<maven.compiler.plugin.version>3.7.0</maven.compiler.plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.plugin.testing.harness.version>3.3.0</maven.plugin.testing.harness.version>
<cobertura.maven.plugin>2.7</cobertura.maven.plugin>
<maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
<plexus.component.annotations.version>1.7.1</plexus.component.annotations.version>
<maven.plugin.annotations.version>3.5</maven.plugin.annotations.version>
<maven.source.plugin.version>2.4</maven.source.plugin.version>
<maven.plugin.annotations.version>3.5.1</maven.plugin.annotations.version>
<maven.source.plugin.version>3.0.1</maven.source.plugin.version>

<gherkin.version>5.0.0</gherkin.version>

<mockito.version>2.9.0</mockito.version>
<mockito.version>2.16.0</mockito.version>
<junit.version>4.12</junit.version>
<openpojo.version>0.8.6</openpojo.version>
<openpojo.version>0.8.10</openpojo.version>
</properties>

<profiles>
Expand Down Expand Up @@ -218,7 +218,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${maven.version}</version>
<version>${maven.compat.version}</version>
</dependency>

<dependency>
Expand Down
21 changes: 17 additions & 4 deletions plugin-code/src/main/java/com/trivago/rta/CucablePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ final class CucablePlugin extends AbstractMojo {
@Parameter(property = "parallel.excludeScenarioTags")
private List<String> excludeScenarioTags;

/**
* Optional log level to control what information is logged in the console.
* Allowed values: default, compact, minimal, off
*/
@Parameter(property = "parallel.logLevel")
private String logLevel = "default";

@Inject
public CucablePlugin(
PropertyManager propertyManager,
Expand All @@ -103,7 +110,7 @@ public CucablePlugin(
*/
public void execute() throws CucablePluginException {
// Initialize logger to be available outside the AbstractMojo class
logger.setMojoLogger(getLog());
logger.initialize(getLog(), logLevel);

// Initialize and validate passed pom properties
propertyManager.setSourceRunnerTemplateFile(sourceRunnerTemplateFile);
Expand All @@ -115,14 +122,20 @@ public void execute() throws CucablePluginException {
propertyManager.setIncludeScenarioTags(includeScenarioTags);
propertyManager.validateSettings();

logger.info("-------------------------------------");
logger.info(String.format(" Cucable Maven Plugin, version %s", getClass().getPackage().getImplementationVersion()));
logger.info("-------------------------------------");
logHeader();
propertyManager.logProperties();

fileManager.prepareGeneratedFeatureAndRunnerDirs();
featureFileConverter.convertToSingleScenariosAndRunners(fileManager.getFeatureFilePaths());
}

private void logHeader() {
CucableLogger.CucableLogLevel[] cucableLogLevels =
new CucableLogger.CucableLogLevel[]{CucableLogger.CucableLogLevel.DEFAULT, CucableLogger.CucableLogLevel.COMPACT};
logger.info("-------------------------------------", cucableLogLevels);
logger.info(String.format(" Cucable Maven Plugin, version %s", getClass().getPackage().getImplementationVersion()), cucableLogLevels);
logger.info("-------------------------------------", cucableLogLevels);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@

import com.trivago.rta.exceptions.CucablePluginException;

import java.util.List;

/**
* Thrown when an expected plugin property is not found or wrong
* (typically set inside a configuration block within the pom file).
*/
public class WrongOrMissingPropertyException extends CucablePluginException {
public class WrongOrMissingPropertiesException extends CucablePluginException {
/**
* Constructor.
*
* @param property The name of the missing property.
* @param properties The name of the missing property.
*/
public WrongOrMissingPropertyException(final String property) {
super("Property '" + property
+ "' is not specified in the configuration section "
+ "of your pom file or contains an invalid value.");
public WrongOrMissingPropertiesException(final List<String> properties) {
super((properties.size() == 1 ? "Property" : "Properties") +
" not specified correctly in the configuration section of your pom file: " + properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,22 @@ String getRenderedFeatureFileContent(SingleScenario singleScenario) {

addLanguage(renderedContent, singleScenario.getFeatureLanguage());
addTags(renderedContent, singleScenario.getFeatureTags());
addFeatureNameAndDescription(
renderedContent, singleScenario.getFeatureName(), singleScenario.getFeatureDescription()
addNameAndDescription(
renderedContent,
singleScenario.getFeatureName(),
singleScenario.getFeatureDescription()
);

addTags(renderedContent, singleScenario.getScenarioTags());
addScenarioNameAndDescription(
renderedContent, singleScenario.getScenarioName(), singleScenario.getScenarioDescription());
addNameAndDescription(
renderedContent,
singleScenario.getScenarioName(),
singleScenario.getScenarioDescription());

addSteps(renderedContent, singleScenario.getBackgroundSteps());
addSteps(renderedContent, singleScenario.getSteps());

addGeneratedByCucumberMessage(renderedContent);
addComments(renderedContent, singleScenario.getFeatureFilePath());

return renderedContent.toString();
}
Expand All @@ -71,10 +75,14 @@ private void addLanguage(final StringBuilder stringBuilder, final String feature
/**
* Adds the "Generated by Cucable" line to the generated feature file content.
*
* @param stringBuilder The current feature {@link StringBuilder} instance.
* @param stringBuilder The current feature {@link StringBuilder} instance.
* @param featureFilePath The path to the source feature file.
*/
private void addGeneratedByCucumberMessage(final StringBuilder stringBuilder) {
private void addComments(final StringBuilder stringBuilder, String featureFilePath) {
stringBuilder.append(LINE_SEPARATOR)
.append("# Source feature: ")
.append(featureFilePath)
.append(LINE_SEPARATOR)
.append("# Generated by Cucable")
.append(LINE_SEPARATOR);
}
Expand All @@ -97,39 +105,20 @@ private void addSteps(final StringBuilder stringBuilder, final List<Step> steps)
}

/**
* Adds the scenario name to the generated feature file content.
* Adds the feature or scenario name and description to the generated feature file content.
*
* @param stringBuilder The current feature {@link StringBuilder} instance.
* @param scenarioName The scenario name.
* @param scenarioDescription The scenario description.
*/
private void addScenarioNameAndDescription(
final StringBuilder stringBuilder,
final String scenarioName,
final String scenarioDescription
) {
stringBuilder.append(scenarioName);
if (scenarioDescription != null && !scenarioDescription.isEmpty()) {
stringBuilder.append(LINE_SEPARATOR).append(scenarioDescription);
}
stringBuilder.append(LINE_SEPARATOR).append(LINE_SEPARATOR);
}

/**
* Adds the feature name to the generated feature file content.
*
* @param stringBuilder The current feature {@link StringBuilder} instance.
* @param featureName The feature name.
* @param featureDescription The feature description.
* @param stringBuilder The current feature {@link StringBuilder} instance.
* @param name The feature or scenario name.
* @param description The feature or scenario description.
*/
private void addFeatureNameAndDescription(
private void addNameAndDescription(
final StringBuilder stringBuilder,
final String featureName,
final String featureDescription
final String name,
final String description
) {
stringBuilder.append(featureName);
if (featureDescription != null && !featureDescription.isEmpty()) {
stringBuilder.append(LINE_SEPARATOR).append(featureDescription);
stringBuilder.append(name);
if (description != null && !description.isEmpty()) {
stringBuilder.append(LINE_SEPARATOR).append(description);
}
stringBuilder.append(LINE_SEPARATOR).append(LINE_SEPARATOR);

Expand Down
Loading

0 comments on commit 1b331f7

Please sign in to comment.