Skip to content

test: updated 3 tests in StringUtilsTest to use parameterized #7295

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

Merged
merged 4 commits into from
Apr 27, 2025

Conversation

Monilnarang
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Summary:

  • Parameterized tests : testIsNullOrEmpty, testIsBlank, testIsNotBlank

Elaboration:

  • The same method calls (isNullOrEmpty, isBlank, isNotBlank) were repeated multiple times with different inputs, making the test harder to maintain and extend.
  • When a test fails, JUnit only shows which assertion failed, but not which specific input caused the failure.
  • Adding new test cases requires copying and pasting another block of statements instead of simply adding new data.

To accomplish this, I retrofitted these tests into a parameterized unit test. This reduces duplication, allows easy extension by simply adding new value sets, and makes debugging easier as it clearly indicates which test failed instead of requiring a search through individual assertions.

Test execution results after changes:
Screenshot 2025-04-13 at 11 30 24 PM

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Successful tests run

Ⅴ. Special notes for reviews

Copy link

codecov bot commented Apr 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.30%. Comparing base (0495f83) to head (13d0ee9).
Report is 1 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7295      +/-   ##
============================================
+ Coverage     54.26%   54.30%   +0.03%     
- Complexity     7267     7271       +4     
============================================
  Files          1178     1178              
  Lines         41962    41962              
  Branches       4923     4923              
============================================
+ Hits          22772    22786      +14     
+ Misses        17038    17022      -16     
- Partials       2152     2154       +2     

see 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@slievrly
Copy link
Member

@Monilnarang Pls resolve conflicts.

@Monilnarang
Copy link
Contributor Author

Done!

@slievrly slievrly changed the title test: updated 3 tests in StringUtilsTest to use parameterized unit testing test: updated 3 tests in StringUtilsTest to use parameterized Apr 27, 2025
@slievrly slievrly added this to the 2.5.0 milestone Apr 27, 2025
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

LGTM

@slievrly slievrly merged commit b268838 into apache:2.x Apr 27, 2025
9 checks passed
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.

2 participants