Skip to content

Improvement: multiple-assertions unit test into parameterized one - #1698

Merged
ohbus merged 2 commits into
iluwatar:masterfrom
eas5:test_improvement
Apr 22, 2021
Merged

ohbus merged 2 commits into
iluwatar:masterfrom
eas5:test_improvement

Conversation

@eas5

@eas5 eas5 commented Apr 8, 2021

Copy link
Copy Markdown
Contributor

Problem:
A test method with many individual assertions stops being executed on the first failed assertion, which prevents the remaining ones' execution. In the refactored method, the difference between the assertions lies within different arguments only.

Solution:
Parameterized tests make it possible to run a test multiple times, with different arguments, as individual and independent tests. This way, we were able to make 1 original test with 9 assertions become 9 independent ones, one for each enumeration element.

Additional change:
Maven dependency concerning the JUnit params library was also added.

Signed-off-by: Elvys Soares <eas5@cin.ufpe.br>
@ohbus ohbus self-assigned this Apr 8, 2021

@ohbus ohbus left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Let us wait to fix the build problem before we could merge this into master.

We need #1699 to be rebased into this PR after it is has been merged

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ohbus
ohbus merged commit af0ccdc into iluwatar:master Apr 22, 2021
@ohbus ohbus added this to the 1.25.0 milestone Apr 22, 2021
@ohbus

ohbus commented Apr 22, 2021

Copy link
Copy Markdown
Contributor

Thank you so much @eas5 for the improvement 🎉

@all-contributors please add @eas5 for code

@allcontributors

Copy link
Copy Markdown
Contributor

@ohbus

I've put up a pull request to add @eas5! 🎉

noamgrinch added a commit to noamgrinch/java-design-patterns that referenced this pull request Apr 22, 2021
refactoring: Added parameterization to enumeration test (iluwatar#1698)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants