Skip to content

Commit

Permalink
docs: Enhance Gradle build configuration including how to use tags
Browse files Browse the repository at this point in the history
issue #119
  • Loading branch information
mikezx6r committed Apr 9, 2018
1 parent 5783454 commit 6b68c87
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/asciidoc/gradle.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,25 @@ A typical use case is to run the tests and to always produce the aggregate repor
gradle test aggregate
----

This will run the tests and generate an aggregate report in the `target/site/thucydides` directory.
This will run the tests and generate an aggregate report in the `target/site/thucydides` directory.

Alternatively, configure Gradle as below by first removing the `gradle.startParameter.continueOnFailure = true` line.

Then add the following lines. As per the comments, this will configure the test task so that it will clear the reports first,
always execute the Serenity tests, won't stop the build if a test fails, and will automatically run the aggregate task.

This means you only need to execute `gradle test` to execute the tests and don't have to worry about previous runs cluttering up the results of this test execution.

[source,groovy]
----
test {
// Ensure reports from a previous run are cleared up
dependsOn clearReports
// Ensure integration tests are always run. Will never report as 'UP-TO-DATE'
outputs.upToDateWhen {false}
// ensure Gradle ignores failing tests so that the Serenity Aggregation step executes
ignoreFailures = true
// Ensure Serenity aggregation is run after, and if, integration tests are run
finalizedBy aggregate
}
----
25 changes: 25 additions & 0 deletions src/asciidoc/tags.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ You can filter tests by tag while running Serenity.
With JUnit tests, this can be achieved by providing a single tag or a comma separated list of tags from command line.
If provided, only classes and/or methods with tags in this list will be executed.

===== Maven Build
[source,xml]
----
mvn clean verify -Dtags="release:sprint-2"
Expand All @@ -149,6 +150,30 @@ or
mvn clean verify -Dtags="feature:Reporting, release:sprint-2"
----

===== Gradle Build
In order to filter with Gradle, the following needs to be added to the configuration of the test task. If it is not present, the value of 'tags' does not get passed to the SerenityRunner, and the tags filter is not applied.

[source,groovy]
----
test {
systemProperty 'tags', System.properties['tags']
}
----

Once this configuration is in place, one can filter in a similar manner to Maven.

[source,xml]
----
gradle test verify -Dtags="release:sprint-2"
----

or

[source,xml]
----
gradle test -Dtags="feature:Reporting, release:sprint-2"
----

==== Cucumber

With Cucumber framework, you need to use the cucumber.options system property for tests filtering.
Expand Down

0 comments on commit 6b68c87

Please sign in to comment.