Skip to content

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

@codecov
Copy link

codecov bot commented Apr 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.49%. Comparing base (b7e4856) to head (4494208).
Report is 1 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7294      +/-   ##
============================================
- Coverage     54.49%   54.49%   -0.01%     
  Complexity     7301     7301              
============================================
  Files          1178     1178              
  Lines         41962    41962              
  Branches       4923     4923              
============================================
- Hits          22869    22867       -2     
- Misses        16925    16927       +2     
  Partials       2168     2168              

see 5 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 slievrly changed the title test: improved test testGetInsertParamsValue in SqlServerInsertRecognizerTest by splitting and parameterizing test: improved test SqlServerInsertRecognizerTest Apr 28, 2025
@slievrly slievrly added this to the 2.5.0 milestone Apr 28, 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 8c72b89 into apache:2.x Apr 28, 2025
9 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
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