Skip to content

Make Test conditions work in Visual Studio #3191

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
Wraith2 opened this issue Mar 2, 2025 · 8 comments
Open

Make Test conditions work in Visual Studio #3191

Wraith2 opened this issue Mar 2, 2025 · 8 comments
Assignees
Labels
Enhancement 💡 Issues that are feature requests for the drivers we maintain. Triage Done ✔️ Issues that are triaged by dev team and are in investigation.

Comments

@Wraith2
Copy link
Contributor

Wraith2 commented Mar 2, 2025

When developing changes or investigating bugs in SqlClient it is important to be able to run the tests. This can be done from the commandline using complex syntax but most people prefer to be able to use the tests from inside visual studio. If try to run tests inside visual studio you will quickly discover that all tests run regardless of their conditions which means that even on a clean working master build you will wait a long time for test failures and have to sort through which failures are expected because they should not have been run.

A simple example is ConnectivityTest.ConnectionAliasTest. This is defined as:

        [PlatformSpecific(TestPlatforms.Windows)]
        [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSQLAliasSetup))]
        public static void ConnectionAliasTest()

The test should not be executed unless it the IsSQLAliasSetup function returns true. I have not configured the alias, that function never returns true. The test is executed anyway.

I'd like to be able to run tests from inside visual studio and have any applied conditions correctly validated preventing tests that cannot succeed from being executed. Being able to evaluate whether the change i'm working on is breaking other parts of the library will enable much quicker testing allowing less reliance on the, no longer available to contributors, CI.

@Wraith2 Wraith2 added Enhancement 💡 Issues that are feature requests for the drivers we maintain. Triage Needed 🆕 For new issues, not triaged yet. labels Mar 2, 2025
@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 3, 2025

@Wraith2 Have you tried this: xunit/xunit#2433 (comment)

@Wraith2
Copy link
Contributor Author

Wraith2 commented Mar 3, 2025

I hadn't tried it. I have now. Makes no difference.

@MichelZ
Copy link
Contributor

MichelZ commented Mar 3, 2025

There's an arcade issue about this (the project which defines the ConditionalFact attribute)
dotnet/arcade#15207 (comment)

@Wraith2
Copy link
Contributor Author

Wraith2 commented Mar 3, 2025

Is it an arcade issue somehow? If it cross-team co-op can still happen and get if fixed which is all I want.

@MichelZ
Copy link
Contributor

MichelZ commented Mar 3, 2025

I do believe it's an issue how the Attribute is coded. Here's another issue into that same direction: dotnet/arcade#15195 (So yes, IMHO it's an issue that can only be solved in the Arcade repo)

@David-Engel
Copy link
Contributor

I never run all tests from the GUI because of this. Just targeted tests. Then I use the command line for broader validation. I find this annoying, too, as I'd rather just use the GUI. Would be nice if it got fixed.

@paulmedynski paulmedynski self-assigned this Mar 4, 2025
@mdaigle mdaigle added Triage Done ✔️ Issues that are triaged by dev team and are in investigation. and removed Triage Needed 🆕 For new issues, not triaged yet. labels Mar 4, 2025
@paulmedynski
Copy link
Contributor

The way we specify, categorize, and filter tests is a big Quality of Life task on my plate. I will own this and drive discussions and changes to improve things going forward.

@akoeplinger
Copy link
Member

I fixed the issue with ConditionalFacts not working in VS with dotnet/arcade#15667, once you upgrade to Microsoft.DotNet.XUnitExtensions version 10.0.0-beta.25175.1 or later it should start working.

The only other thing you need to do is add a .runsettings file that filters out the category=failing tests (which is what ActiveIssue and a couple other attributes use).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 💡 Issues that are feature requests for the drivers we maintain. Triage Done ✔️ Issues that are triaged by dev team and are in investigation.
Projects
None yet
Development

No branches or pull requests

7 participants