-
Notifications
You must be signed in to change notification settings - Fork 716
SONARJAVA-5973 Improve testkit tool to be able to use specific dependencies for tests #5401
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
Conversation
leonardo-pilastri-sonarsource
left a comment
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.
I think it's a very nice improvement to have! I would change the method name and also add some specific tests for the JavaCheckVerifier
| * @param jarsToRemove a collection of jar names (without extensions) to remove from the classpath | ||
| * @return the verifier configured to use the dependencies provided as arguments to change the classpath | ||
| */ | ||
| CheckVerifier withDependenciesToChange(List<String> jarsToAdd, List<String> jarsToRemove); |
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.
I think I'd rather have two separate methods, one to remove some jars, and the other to add them, this way we don't have the overhead of the order of parameters, and can also avoid handling null cases.
We could have something like
CheckVerifier removeJarsFromClasspath(String... jarsToRemove);
CheckVerifier addJarsToClasspath(String... jarsToAdd);
...cks-testkit/src/main/java/org/sonar/java/checks/verifier/internal/InternalCheckVerifier.java
Show resolved
Hide resolved
|
|
||
| @Override | ||
| public CheckVerifier withDependenciesToChange(List<String> jarsToAdd, List<String> jarsToRemove) { | ||
| this.jarsToAdd = jarsToAdd; |
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.
If we want to override we should be clear about it, from the javadoc and the signature I might think that everytime I call this method I am defining more libraries to add/remove on top of previous calls to the method.
I think if we switch to removeJarsFromClasspath and addJarsToClasspath, the implementation should also change to be "cumulative", so multiple calls would produce the expected result
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.
Oh, yep, I've completely forgot about verifier's tests... You're right, will do!
leonardo-pilastri-sonarsource
left a comment
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.
Looks good! Thanks a lot for the nice work!!
b2db71b to
a112404
Compare
…encies for tests
a112404 to
4efefcb
Compare
|




Added CheckVerifier.withDependenciesToChange() method to configure needed dependencies to add / remove from a classpath. See SONARJAVA-5973