-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore: ArtifactHandlerTest improve tests on packaging
#2375
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
@SuppressWarnings("checkstyle:UnusedLocalVariable")ArtifactHandlerTest add test assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable")
ArtifactHandlerTest add test assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable")ArtifactHandlerTest add assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable")
impl/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
Outdated
Show resolved
Hide resolved
b60fd48 to
bc0ea91
Compare
bc0ea91 to
44a5d95
Compare
impl/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
Outdated
Show resolved
Hide resolved
44a5d95 to
582c71a
Compare
| assertEquals(handler.getExtension(), extension, type + " extension"); | ||
| // Packaging/Directory is Maven1 remnant!!! | ||
| // assertEquals(handler.getPackaging(), packaging, type + " packaging"); | ||
| assertThat(handler.getPackaging()).contains(packaging); |
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.
test-jar != jar
this could be investigated, if only this is a combination not matching and why so.
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.
could merge will check up.
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 don't understand why we're not just using assertEquals here.
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.
because test-jar != jar might be the only exception, but equals is the right but not working.
This could be an bug because the packaging is different. Will investigate.
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.
all hyphen needs contains. we can continue but i wont want to ask any more questions and would take increment.
Whats your call?
582c71a to
7872cca
Compare
7872cca to
f6c6200
Compare
Pankraz76
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.
smell.
| assertEquals("jar", packaging); | ||
|
|
||
| } else if (handler.getPackaging().equals("ejb-client")) { | ||
| assertEquals("ejb", packaging); |
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.
both look like bug to me. maven-archetype",
"maven-plugin", "java-source" are all equal so why not these two ? So its not a hyphen thing in general, right?
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 might be starting to see what's going on here. I think you're hitting a weird issue (though WAI) about file extension vs dependency type. See https://maven.apache.org/ref/3.9.9/maven-core/artifact-handlers.html and pages I can't put my finger on right now, but updated a few months ago.
That being said, I am more convinced now that this approach is incorrect. We want one single assertEquals that tests a specific value, not contains something from a collection and not "if this assert that". This might mean splitting into multiple test methods. DRY does not apply to tests and asserts. Unit tests should be very straight-forward with no branching and no conditionals.
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.
agree.
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.
f6c6200 to
6a90f9b
Compare
| assertEquals("jar", packaging); | ||
|
|
||
| } else if (handler.getPackaging().equals("ejb-client")) { | ||
| assertEquals("ejb", packaging); |
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 might be starting to see what's going on here. I think you're hitting a weird issue (though WAI) about file extension vs dependency type. See https://maven.apache.org/ref/3.9.9/maven-core/artifact-handlers.html and pages I can't put my finger on right now, but updated a few months ago.
That being said, I am more convinced now that this approach is incorrect. We want one single assertEquals that tests a specific value, not contains something from a collection and not "if this assert that". This might mean splitting into multiple test methods. DRY does not apply to tests and asserts. Unit tests should be very straight-forward with no branching and no conditionals.
ArtifactHandlerTest add assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable")ArtifactHandlerTest improve tests on packaging
6a90f9b to
d67f637
Compare
| container.lookup(ArtifactHandlerManager.class).getArtifactHandler(type); | ||
| assertEquals(handler.getExtension(), extension, type + " extension"); | ||
| // Packaging/Directory is Maven1 remnant!!! | ||
| // assertEquals(handler.getPackaging(), packaging, type + " packaging"); |
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.
better some special workaround assert than no at all!
Agree upon test code allowed some flexibility like having commented out code. So lets use this liberty to improve the test by testing the production code.
This topic remains, but we have cleared up the doing and increased coverage.
If/as no ability to fix it yet, might consider take the increment and go for next increment.
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.
can we resolve conversation and go for next increment? Its already an win, as removing dead code and improve context.
provide only fixup for UnusedLocalVariable, no refactoring like in
@SuppressWarnings("checkstyle:UnusedLocalVariable")#2365