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
Replace similar OS EoL tests with @ParameterizedTests
#8153
Replace similar OS EoL tests with @ParameterizedTests
#8153
Conversation
Hey @Chrimle, how did you test the changes proposed? There are several flaws violating Java logic. |
Not sure why these changes were not part of the PR...
Hello @NotMyFault ! I just went back and fixed that locally instead. |
CI failed due to formatting violation.
No objections from me. The parameterized tests are a nice way of reducing the duplication. |
Happy you like it :) Question is if the strings should be replaced with constants - for example, the 2 first arguments are common for the 2 ParameterizedTests. In the example; The 2 first strings are repeated in the second test: This is very minor, and I don't expect anyone to tweak existing test cases. However, in the future, whenever more OS's are added to these test cases - it may be easy to make a mistake? |
I don't think it will help test readability to replace the strings with constants. The first argument is a file name from the resources. Duplication of the resource filename in the source code is not a concern for me because I think it keeps the test more readable. I have tests in a plugin that iterate over resource filenames so that the resource names are not in the source code. I find it more difficult to diagnose failures in those tests because the resource being read is not immediately apparent in the source. The second argument is the matching pattern. That matching pattern is duplicated from inside the JSON file so that the test only asserts on the documentation url. The test could be rewritten to use the matching pattern from the JSON so that the duplicate of the matching pattern is removed from the test, but then the test would rely on the JSON file contents more and might fail to detect inconsistencies. |
@ParameterizedTests
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.
Thanks a lot!
/label ready-for-merge
This PR is now ready for merge. We will merge it after ~24 hours if there is no negative feedback.
Please see the merge process documentation for more information about the merge process.
Thanks!
Congratulations on getting your very first Jenkins core pull request merged 🎉🥳 |
OperatingSystemEndOfLifeAdminMonitorTest.java
contains tests for getting the OS name, and tests for reading documentation based on the OS.These tests are simple, and only differ in the
String
s for the input and expected output from the method(s) tested. Hence, these test cases can be replaced by@ParameterizedTests
.It is certainly possible to reduce the two
@MethodSource
s into one, but would leave oneArgument
unused in both tests.