Skip to content

Commit 0e4ce4f

Browse files
ICT-KayneSkris-jusiak
authored andcommitted
Added Location selection for Cucumber.json output
Added Fail message to Cucumber.json output
1 parent 56ce00e commit 0e4ce4f

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

include/GUnit/GSteps.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,10 @@ class Steps : public ::testing::EmptyTestEventListener {
306306
::testing::UnitTest::GetInstance()->listeners().Append(this);
307307
// If the output is set, then add a report to the features holder
308308
const auto output = std::getenv("OUTPUT");
309-
std::string path = std::string(output) + std::string(std::getenv("TEST_NAME"));
310-
std::cout << path << std::endl;
309+
311310
if (output) {
311+
std::string path = std::string(output) + std::string(std::getenv("TEST_NAME"));
312+
std::cout << path << std::endl;
312313
Features::getInstance()->addReport(path);
313314
}
314315
for (const auto& feature : detail::split(scenario, ':')) {
@@ -644,6 +645,7 @@ class Steps : public ::testing::EmptyTestEventListener {
644645
;
645646
if (currentStep == nullptr) return;
646647
currentStep->setResult(!(test_part_result.failed()));
648+
currentStep->setFailMessage(test_part_result.summary());
647649
}
648650

649651
std::shared_ptr<GherkinCpp::Step>

include/formatters/cucumberjson.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CucumberJson {
6565
std::string resultStr = step.second->getResult()?"passed":"failed";
6666
curStep["result"] = {
6767
{"status", resultStr},
68+
{"error_message", step.second->getFailMessage()},
6869
{"duration", 1}
6970
};
7071
curElement["steps"].push_back(curStep);

include/formatters/gherkinCpp/step.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ class Step : public GenericInfo{
2424
result = result_;
2525
}
2626

27+
void setFailMessage(const char* message_) {
28+
message = std::string(message_);
29+
}
30+
2731
bool getResult() { return result;}
32+
std::string getFailMessage() {return message;}
2833

2934
private:
3035
bool result=true;
36+
std::string message;
3137
};
3238

3339
} // GherkinCpp

0 commit comments

Comments
 (0)