Skip to content

Conversation

@TheRealHaui
Copy link
Contributor

Added new Unit Tests

@cstamas cstamas requested a review from gnodet December 2, 2025 11:23
@gnodet
Copy link
Contributor

gnodet commented Dec 3, 2025

@TheRealHaui You need to run mvn spotless:apply to correctly format the source code.

@TheRealHaui
Copy link
Contributor Author

@gnodet,
I know ... or better actually I thought I know or whatever ...
Thought I did it.
However, NOW I really did it.
Thanks for the hint!

private Plugin pluginOne;
private Plugin pluginTwo;

@BeforeEach
Copy link
Contributor

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

Copy link
Contributor Author

@TheRealHaui TheRealHaui Dec 5, 2025

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

private Plugin pluginOne;
private Plugin pluginTwo;

@BeforeEach
Copy link
Contributor

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);

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants