CLI

In scope of this article the task term is a piece of work that is done on stories, scenarios, steps and other entities and that produces some output based on the work done.

Example 1. The format of a task
./gradlew <task to perform>
Example 2. The format of a task with arguments
./gradlew <task to perform> --args='<arguments to pass into the task>'
The tasks are available only through the gradlew command.

Run stories

The task runs test stories based on current tests configuration and tests state on the file system.

Example 3. macOS / Linux:
./gradlew runStories
Example 4. Windows:
gradlew runStories

Treat known issues only as a positive result

Any known issues detected during stories run fail the overall execution with the corresponding exit code. The following command-line option can be used to not treat known issues as failures:

Example 5. Enable treating of known issues as a positive result for current stories run
./gradlew runStories --treat-known-issues-only-as-passed

The treating of known issues as a positive result can be enabled globally at the project level by adding the following line into the build.gradle file of the tests project:

Example 6. Enable treating of known issues as positive result for stories exeuctions at the project level
runStories.treatKnownIssuesOnlyAsPassed = true

Make sure to put the configuration below the line configuring the project tasks, namely:

apply from: "$\{buildSystemPath\}/vividus-test-project.gradle"
...

Write exit code to a file

Writing of the exit code can be enabled globally using project properties:

Example 7. Write exit code to a file by an absolute path via CLI
./gradlew runStories -PfileToSaveExitCode='/user/dir/exitCode.txt'
Example 8. Write an exit code to a file with a path related to the project build directory via CLI
./gradlew runStories -PfileToSaveExitCode='/exitCode.txt' -PresolvePathAgainstProjectBuildDir=true

Writing of the exit code can be enabled globally for the project by adding the following lines into the build.gradle file of the test project:

Example 9. Write the exit code to a file by an absolute path via the project property
runStories.fileToSaveExitCode ='/user/dir/exitCode.txt'
Example 10. Write an exit code to file with a path related to the project build directory via project property
runStories.fileToSaveExitCode = '/exitCode.txt'
runStories.resolvePathAgainstProjectBuildDir = true

Debug stories

The task runs test stories omitting VIVIDUS initialization check based on current tests configuration and tests state on the file system.

Example 11. macOS / Linux:
./gradlew runStories
Example 12. Windows:
gradlew runStories

Treat known issues only as a positive result

Any known issues detected during stories run fail the overall execution with the corresponding exit code. The following command-line option can be used to not treat known issues as failures:

Example 13. Enable treating of known issues as a positive result for current stories run
./gradlew runStories --treat-known-issues-only-as-passed

The treating of known issues as a positive result can be enabled globally at the project level by adding the following line into the build.gradle file of the tests project:

Example 14. Enable treating of known issues as positive result for stories exeuctions at the project level
runStories.treatKnownIssuesOnlyAsPassed = true

Make sure to put the configuration below the line configuring the project tasks, namely:

apply from: "$\{buildSystemPath\}/vividus-test-project.gradle"
...

Write exit code to a file

Writing of the exit code can be enabled globally using project properties:

Example 15. Write exit code to a file by an absolute path via CLI
./gradlew runStories -PfileToSaveExitCode='/user/dir/exitCode.txt'
Example 16. Write an exit code to a file with a path related to the project build directory via CLI
./gradlew runStories -PfileToSaveExitCode='/exitCode.txt' -PresolvePathAgainstProjectBuildDir=true

Writing of the exit code can be enabled globally for the project by adding the following lines into the build.gradle file of the test project:

Example 17. Write the exit code to a file by an absolute path via the project property
runStories.fileToSaveExitCode ='/user/dir/exitCode.txt'
Example 18. Write an exit code to file with a path related to the project build directory via project property
runStories.fileToSaveExitCode = '/exitCode.txt'
runStories.resolvePathAgainstProjectBuildDir = true

Print available steps

The task prints all the steps that are available for the configured profiles, environments and suites in the alphabetical order.

Table 1. Options
Description Short notation Full notation Default value

Path to a file to save the list of the available steps

f

file

by default steps are printed into the console

Example 19. macOS / Linux:
./gradlew printSteps --args='-f my-steps.txt'
Example 20. Windows:
gradlew printSteps --args='-f my-steps.txt'
Example 21. Output
vividus                                             Then `$value` matches `$regex`
vividus-plugin-web-app                              When I switch back to page
vividus-plugin-web-app                              When I press $keys on keyboard
                            COMPOSITE IN STEPS FILE Then an element with the name '$elementName' exists
                            COMPOSITE IN STEPS FILE When I click on an image with the name '$imageName'

Count steps

The task counts steps in the specified tests folder and prints them in the descending order.

Table 2. Options
Description Short notation Full notation Default value

Directory to count steps

d

dir

story

Number of steps to print

t

top

<no limits by default>

Example 22. macOS / Linux:
./gradlew countSteps --args='-t 5 -d story/uat'
Example 23. Windows:
gradlew countSteps --args='-t 5 -d story/uat'
Example 24. Output
Top of the most used steps:                                                                  occurrence(s)
Then `$variable1` is $comparisonRule `$variable2`                                                      330
Given I am on page with URL `$pageURL`                                                                 127
Then number of elements found by `$locator` is $comparisonRule `$quantity`                             110
Given I initialize $scopes variable `$variableName` with value `$variableValue`                         83
When I change context to element located `$locator`                                                     59

Count scenario

The task counts and prints stories, scenarios and scenarios containing examples found in the specified tests folder.

Table 3. Options
Description Short notation Full notation Default value

Directory to count stories and scenarios

d

dir

story

Example 25. macOS / Linux:
./gradlew countScenarios --args='-d story/uat'
Example 26. Windows:
gradlew countScenarios --args='-d story/uat'
Example 27. Output
5  | Stories
13 | Scenarios
6  | Scenarios with Examples

Validate known issues configuration

The task validates known issues format and prints the validated known issues into the console.

Example 28. macOS / Linux:
./gradlew validateKnownIssues
Example 29. Windows:
./gradlew validateKnownIssues
Example 30. Output
Known issues found:
VVD-5
VVD-6
VVD-7
VVD-8

Find known issues by assertion pattern

The task used to find known issues contained in the test project by one or more assertion patterns.

Table 4. Options
Description Short notation Full notation Default value

Required path to a file that contains new-line-separated list of assertion patterns

f

file

<no default value>

If you miss the file argument into the task it will behave as described per Validate known issues configuration
Example 31. assertion-patterns.txt
.*Doctor Who.*
Example 32. macOS / Linux:
./gradlew validateKnownIssues --args='-f ./assertion-failures.txt'
Example 33. Windows:
gradlew validateKnownIssues --args='-f assertion-failures.txt'
Example 34. Output
Known Issue | Assertion Error
VVD-6       | .*Doctor Who.*

Replace deprecated steps

The task replaces deprecated steps with actual ones in all stories(*.story files) and composite steps (*.steps files) along the path <project-name>/src/main/resources. Please note that some deprecated steps (for example which should be replaced with two steps) cannot be replaced automatically and must be refactored manually.

Example 35. macOS / Linux:
./gradlew replaceDeprecatedSteps
Example 36. Windows:
gradlew replaceDeprecatedSteps
Example 37. Output (for cases when found steps which cannot be replaced automatically)
The step "When I check all checkboxes located by `xpath(.//input)`" from "CheckboxStepsTests.story - Scenario: Validation of step 'When I $checkboxState all checkboxes located by `$checkboxesLocator`'" is deprecated but cannot be replaced automatically, please replace it manually.
The step "When I check all checkboxes located by `xpath(.//input)`" from "composite.steps - Composite: When I run composite step with table:$table" is deprecated but cannot be replaced automatically, please replace it manually.

Replace deprecated properties

The task replaces deprecated properties with actual ones in all properties files along the path <project-name>/src/main/resources/properties.

Example 38. macOS / Linux:
./gradlew replaceDeprecatedProperties
Example 39. Windows:
gradlew replaceDeprecatedProperties

The examples below demonstrate property file with deprecated properties before and after applying the replaceDeprecatedProperties task.

Example 40. Property file with deprecated entries before running the task replaceDeprecatedProperties
ui.visual.applitools.server-uri=https://eyes.applitools.com/
ui.visual.applitools.app-name=name
web.driver.CHROME.experimental-options={"prefs": {"profile": {"cookie_controls_mode": 0}}}
batch-6.story-execution-timeout=PT15M
Example 41. Property file with replaced entries after running the task replaceDeprecatedProperties
applitools.server-uri=https://eyes.applitools.com/
applitools.app-name=name
web.driver.chrome.experimental-options={"prefs": {"profile": {"cookie_controls_mode": 0}}}
batch-6.story.execution-timeout=PT15M