-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add per-step duration to JUnit XML system-out #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,15 +80,15 @@ namespace cucumber_cpp::library::formatter | |
| }; | ||
| } | ||
|
|
||
| std::string FormatStep(const cucumber::messages::step& gherkinStep, const cucumber::messages::pickle_step& pickleStep, cucumber::messages::test_step_result_status status) | ||
| std::string FormatStep(const cucumber::messages::step& gherkinStep, const cucumber::messages::pickle_step& pickleStep, cucumber::messages::test_step_result_status status, std::chrono::milliseconds duration) | ||
| { | ||
| auto statusString = std::string{ cucumber::messages::to_string(status) }; | ||
| std::transform(statusString.begin(), statusString.end(), statusString.begin(), [](unsigned char c) | ||
| { | ||
| return std::tolower(c); | ||
| }); | ||
|
|
||
| return fmt::format("{:.<76}{}", util::Trim(gherkinStep.keyword) + " " + util::Trim(pickleStep.text), statusString); | ||
| return fmt::format("{:.<76}{} ({} ms)", util::Trim(gherkinStep.keyword) + " " + util::Trim(pickleStep.text), statusString, duration.count()); | ||
| } | ||
|
|
||
| std::string MakeOutput(query::Query& query, const cucumber::messages::test_case_started& testCaseStarted) | ||
|
|
@@ -105,7 +105,8 @@ namespace cucumber_cpp::library::formatter | |
| const auto [testStepFinished, testStep] = pair; | ||
| const auto& pickleStep = *query.FindPickleStepBy(*testStep); | ||
| const auto& gherkinStep = query.FindStepBy(pickleStep); | ||
| return FormatStep(gherkinStep, pickleStep, testStepFinished->test_step_result.status); | ||
| const auto durationMs = util::DurationToMilliseconds(query.FindTestStepDurationByTestStepId(testStepFinished->test_step_id)); | ||
| return FormatStep(gherkinStep, pickleStep, testStepFinished->test_step_result.status, durationMs); | ||
|
Comment on lines
+108
to
+109
|
||
| }); | ||
|
|
||
| return fmt::format("\n{}\n", fmt::join(outputView, "\n")); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file now names
std::chrono::millisecondsin theFormatStepsignature, but it doesn’t include<chrono>directly (it currently relies on transitive inclusion viautil/Duration.hpp). Consider adding an explicit#include <chrono>here to follow include hygiene / IWYU and avoid brittle builds if headers change.