Skip to content

test: improved test testGetInsertParamsValue in SqlServerInsertRecognizerTest by splitting and parameterizing #7294

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

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from

Conversation

Monilnarang
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Summary:

  • Separated independent logics inside the aforementioned test, i.e. checking for explicit values and default value.
  • Parameterized the test with explicit values

Elaboration:

  • The same method calls (getSQLStatement, creating recognizer) were repeated multiple times with different inputs, making the test harder to maintain and extend.
  • The test also had 2 independent logics of checking for explicit values and default value under single test.
  • 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 separated the 2 logics into different test and then retrofitted the explicit values test 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. The separated tests also increase the fault detection capabilities of the suit.

Test execution results after changes:
Screenshot 2025-04-13 at 11 10 49 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.21%. Comparing base (b1f0c04) to head (32d852e).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7294      +/-   ##
============================================
- Coverage     54.21%   54.21%   -0.01%     
  Complexity     7267     7267              
============================================
  Files          1178     1178              
  Lines         41969    41969              
  Branches       4926     4926              
============================================
- Hits          22754    22753       -1     
- Misses        17063    17064       +1     
  Partials       2152     2152              

see 6 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.

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.

1 participant