Skip to content

Conversation

@carlos-granados
Copy link
Contributor

The information that shows the time spent to run each test in the JSON and JUnit formatters is interesting if you are trying to optimise the performance of your tests but in many other cases you may only be interested in whether the tests pass or not and this timer information will be of no interest to you. This PR adds a "timer" option to these formatters (similar to the one already available in the pretty and progress formatters) that can be used to disable the output of this data. It defaults to true to preserve existing functionality

"""

Scenario: Editor URL does not affect JSON formatter paths
Given I clear the default behat options
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default all our Behat tests are run with the "timer" option of the formatter set to false (so that timer output does not pollute what we are checking), and since this will now affect the output of the JSON and JUnit formatters, we need to disable this default option in several places

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine as-is, but I would actually be tempted to go the other way, and remove all the time: -IGNORE-VALUE- / time="-IGNORE-VALUE-" from the JSON/JUnit examples in features where it's not relevant (e.g. just keeping it in the main json_format and junit_format feature files).

I think having this new option is an opportunity to make our feature files more robust / less confusing by reducing the number of places we need to implement magic to translate the specification to / from the actual output?

"type": "object",
"additionalProperties": false,
"required": ["tests", "skipped", "failed", "pending", "undefined", "time", "suites"],
"required": ["tests", "skipped", "failed", "pending", "undefined", "suites"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "time" property is now optional

Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @carlos-granados, just a small suggestion on the feature files for the unrelated features.

"""

Scenario: Editor URL does not affect JSON formatter paths
Given I clear the default behat options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine as-is, but I would actually be tempted to go the other way, and remove all the time: -IGNORE-VALUE- / time="-IGNORE-VALUE-" from the JSON/JUnit examples in features where it's not relevant (e.g. just keeping it in the main json_format and junit_format feature files).

I think having this new option is an opportunity to make our feature files more robust / less confusing by reducing the number of places we need to implement magic to translate the specification to / from the actual output?

@acoulton
Copy link
Contributor

The information that shows the time spent to run each test in the JSON and JUnit formatters is interesting if you are trying to optimise the performance of your tests but .in many other cases ... this timer information will be of no interest to you

The other usecase I guess (e.g. with the junit) is if you have tooling aggregating results across all builds - it can be useful to spot performance regressions / improvements over time.

But I agree that having the option to disable it is very helpful.

@carlos-granados
Copy link
Contributor Author

@acoulton good shout about removing the timer info from all tests where it is not relevant, I updated them

Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks @carlos-granados

@carlos-granados carlos-granados merged commit aa88909 into Behat:master Oct 28, 2025
19 checks passed
@carlos-granados carlos-granados deleted the optional-time-json-junit branch October 28, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants