Skip to content

Commit

Permalink
Added GSTEPS documentation
Browse files Browse the repository at this point in the history
Changed Cucumber.json environment variable
from OUTPUT to OUTPUT_CUCUMBER_JSON
  • Loading branch information
ICT-KayneS authored and kris-jusiak committed Sep 13, 2023
1 parent 0e4ce4f commit bc6a5b2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions docs/GSteps.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,55 @@ GSTEPS("Calc*") {
SCENARIO="test/Features/Calc/addition.feature" ./test --gtest_filter="Calc Addition.Add two numbers"
```

##### Cucumber.json output

GSteps also supports the output of Cucumber.json files
enable this by setting the following environment variables:

```sh
OUTPUT_CUCUMBER_JSON=<your output location>
TEST_NAME=<your test name>
```
the OUTPUT_CUCUMBER_JSON variable can be set in the CMakePreset.json file.
and the test name will be automatically set by the test runner if you define the tests using the `test()` function in the CMakeLists.txt file and use the ctest command to run your tests.

##### Example

###### Define tests
The CMake preset file test preset:
```json
"testPresets": [
{
"name": "gcc",
"configurePreset": "gcc",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": false
},
"environment":
{
"OUTPUT_CUCUMBER_JSON": "${sourceDir}/TestResults/"
}
}
]
```

The CMakeLists.txt file defines a test executable with multiple scenarios:
```
test( test/Features/Calc/Steps/CalcSteps SCENARIO=${CMAKE_CURRENT_SOURCE_DIR}/test/Features/Calc/addition.feature:${CMAKE_CURRENT_SOURCE_DIR}/test/Features/Calc/additionfile2.feature)
```

The test runner will automatically set the TEST_NAME environment variable to the name of the test executable.

###### Build and run tests
```sh
cmake --build -j --preset=gcc
ctest --preset=gcc
```

### GWT and Mocking?

```cpp
Expand Down
2 changes: 1 addition & 1 deletion include/GUnit/GSteps.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Steps : public ::testing::EmptyTestEventListener {
if (scenario) {
::testing::UnitTest::GetInstance()->listeners().Append(this);
// If the output is set, then add a report to the features holder
const auto output = std::getenv("OUTPUT");
const auto output = std::getenv("OUTPUT_CUCUMBER_JSON");

if (output) {
std::string path = std::string(output) + std::string(std::getenv("TEST_NAME"));
Expand Down

0 comments on commit bc6a5b2

Please sign in to comment.