jenkinsci / junit-plugin

Allows JUnit-format test results to be published
https://plugins.jenkins.io/junit
MIT License
75 stars 334 forks source link

Add start time fields and logic for setting start time of results in epoch milliseconds #596

Closed bheleker closed 8 months ago

bheleker commented 8 months ago

…s, test packages, and test suites

This pull request is to add information about start times to the different test result classes. Start times are recorded using epoch milliseconds. Many tests in JUnit (and even more converted to JUnit via other plugins i.e. xUnit) include start times for test suites as well as test cases which could be useful information for third-party plugins to have. The default value is -1 for an unset start time and the package start time is the earliest start time of its test cases. Additionally, the overall test result start time is the earliest set start time of a SuiteResult. The largest adds are the parseTime method for parsing the epoch millisecond time from a timestamp and the logic for setting start times. It is intended to be as non-invasive as possible, so no logic is introduced to derive the start time of a test class, but that can be derived by those that want to use the start times. This introduces no breaking changes and no change to the frontend. It will not affect the performance or output of the plugin itself and only introduces more possible information for those extending the plugin.

Testing done

No unit tests were added for the change. However, I made the change alongside my development of an extended TestDataPublisher for pseudo-tracing and metric data collection and was able to verify that start time for suites and test cases matched what was parsed from their reports. Additionally, all unit tests are still passing as the parsing of a start time does not affect the plugin's performance. Omission of a start time simply means it is set to -1 which I verified when testing my extension. Additionally, inclusion of a non-ISO start time results in a LOGGER.warning but does not affect the program's ability to run.

### Submitter checklist
- [x ] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x ] Ensure that the pull request title represents the desired changelog entry
- [x ] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [x ] Ensure you have provided tests - that demonstrates feature works or fixes the issue
bheleker commented 8 months ago

generally looks fine, some formatting issues need fixing and can you please add some test coverage

I've fixed the formatting and added unit tests for parseTime. When I have time I will add some tests for startTime after parsing xml.

Thanks

bheleker commented 8 months ago

I have completed updates to startTime logic and added unit tests for the parseTime function and the start times from a jUnit test result file

timja commented 8 months ago

not manually tested