-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add tests #11509
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
base: master
Are you sure you want to change the base?
Add tests #11509
Conversation
|
@TheRealHaui You need to run mvn spotless:apply to correctly format the source code. |
|
@gnodet, |
| private Plugin pluginOne; | ||
| private Plugin pluginTwo; | ||
|
|
||
| @BeforeEach |
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 just initialize the fields
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.
Which then would lead every test method having
private Plugin pluginOne = new Plugin();
private Plugin pluginTwo = new Plugin();
at the beginning repeatedly.
Don't you think that using the (at)BeforeEach approach is better?
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.
No, that is not how JUnit works. Just initialize the fields. A new test object is used for every test.
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 knew of course because of the way JUnit works that it specifically instantiates objects.
However, wasn't aware of that - test adapted and pushed.
impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeBuilderTest.java
Outdated
Show resolved
Hide resolved
| private Plugin pluginOne; | ||
| private Plugin pluginTwo; | ||
|
|
||
| @BeforeEach |
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.
No, that is not how JUnit works. Just initialize the fields. A new test object is used for every test.
| XmlNode node1 = XmlService.read(r); | ||
| XmlNode node2 = XmlService.read(r); | ||
| assertEquals(node1, node2); | ||
|
|
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.
This should be a separate test method
Added new Unit Tests