Skip to content

Commit bc6a5b2

Browse files
ICT-KayneSkris-jusiak
authored andcommitted
Added GSTEPS documentation
Changed Cucumber.json environment variable from OUTPUT to OUTPUT_CUCUMBER_JSON
1 parent 0e4ce4f commit bc6a5b2

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

docs/GSteps.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,55 @@ GSTEPS("Calc*") {
176176
SCENARIO="test/Features/Calc/addition.feature" ./test --gtest_filter="Calc Addition.Add two numbers"
177177
```
178178

179+
##### Cucumber.json output
180+
181+
GSteps also supports the output of Cucumber.json files
182+
enable this by setting the following environment variables:
183+
184+
```sh
185+
OUTPUT_CUCUMBER_JSON=<your output location>
186+
TEST_NAME=<your test name>
187+
```
188+
the OUTPUT_CUCUMBER_JSON variable can be set in the CMakePreset.json file.
189+
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.
190+
191+
##### Example
192+
193+
###### Define tests
194+
The CMake preset file test preset:
195+
```json
196+
"testPresets": [
197+
{
198+
"name": "gcc",
199+
"configurePreset": "gcc",
200+
"output": {
201+
"outputOnFailure": true
202+
},
203+
"execution": {
204+
"noTestsAction": "error",
205+
"stopOnFailure": false
206+
},
207+
"environment":
208+
{
209+
"OUTPUT_CUCUMBER_JSON": "${sourceDir}/TestResults/"
210+
}
211+
}
212+
]
213+
```
214+
215+
The CMakeLists.txt file defines a test executable with multiple scenarios:
216+
```
217+
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)
218+
```
219+
220+
The test runner will automatically set the TEST_NAME environment variable to the name of the test executable.
221+
222+
###### Build and run tests
223+
```sh
224+
cmake --build -j --preset=gcc
225+
ctest --preset=gcc
226+
```
227+
179228
### GWT and Mocking?
180229

181230
```cpp

include/GUnit/GSteps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class Steps : public ::testing::EmptyTestEventListener {
305305
if (scenario) {
306306
::testing::UnitTest::GetInstance()->listeners().Append(this);
307307
// If the output is set, then add a report to the features holder
308-
const auto output = std::getenv("OUTPUT");
308+
const auto output = std::getenv("OUTPUT_CUCUMBER_JSON");
309309

310310
if (output) {
311311
std::string path = std::string(output) + std::string(std::getenv("TEST_NAME"));

0 commit comments

Comments
 (0)