Skip to content

[SqlClient] Fix test for .NET Framework #2826

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 2 commits into
base: main
Choose a base branch
from

Conversation

martincostello
Copy link
Member

@martincostello martincostello commented Jun 9, 2025

Changes

Update test cases for different behaviour between .NET Framework and .NET.

Discovered after I ran dotnet test on my Windows 11 machine.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added the comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient label Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.82%. Comparing base (71655ce) to head (0d456ae).
Report is 880 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2826       +/-   ##
===========================================
+ Coverage   73.91%   87.82%   +13.91%     
===========================================
  Files         267        9      -258     
  Lines        9615      460     -9155     
===========================================
- Hits         7107      404     -6703     
+ Misses       2508       56     -2452     
Flag Coverage Δ
unittests-Instrumentation.SqlClient 87.82% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 270 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello marked this pull request as ready for review June 9, 2025 12:09
@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 12:09
@martincostello martincostello requested a review from a team as a code owner June 9, 2025 12:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Updates the SqlClient integration tests to handle differing stored-procedure behavior between .NET Framework and .NET by adjusting the InlineData parameters under conditional compilation.

  • Added #if NETFRAMEWORK/#else around stored-procedure InlineData to use a null expected operation name on .NET Framework
  • Split and adjusted test data for each framework case
Comments suppressed due to low confidence (2)

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientIntegrationTests.cs:32

  • Add a brief comment above this conditional block explaining why .NET Framework uses a null expected operation name, so future maintainers understand the behavioral difference.
#if NETFRAMEWORK

test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientIntegrationTests.cs:33

  • [nitpick] Add tests for toggling other flags (e.g., statement collection or parameter inclusion) in the stored-procedure scenario, similar to the text-command cases, to ensure consistent test coverage.
[InlineData(CommandType.StoredProcedure, "sp_who", false, null)]

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jun 17, 2025
@martincostello martincostello force-pushed the fix-sqlclient-netfx-test branch from fcc4955 to 90e6a77 Compare June 17, 2025 05:55
@@ -29,7 +29,12 @@ public SqlClientIntegrationTests(SqlClientIntegrationTestsFixture fixture)
[InlineData(CommandType.Text, "select 1/0", false, null, true)]
[InlineData(CommandType.Text, "select 1/0", false, null, true, false, false)]
[InlineData(CommandType.Text, "select 1/0", false, null, true, true, false)]
#if NETFRAMEWORK
[InlineData(CommandType.StoredProcedure, "sp_who", false, null)]
#else
[InlineData(CommandType.StoredProcedure, "sp_who", false, "sp_who")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this test fail on NetFx ?

I'm trying to determine if we have problem with the CI.

Copy link
Member Author

Choose a reason for hiding this comment

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

Before the fix, it failed 100% of the time on my laptop, which is how I found it.

I did have a similar thought as to why CI wasn't failing, but I couldn't see anything obvious that explained it.

@github-actions github-actions bot removed the Stale label Jun 18, 2025
Update test cases for different behaviour between .NET Framework and .NET.
Avoid duplicated row.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants