Skip to content

ConditionalFact does not work from within VS #7862

Description

@weltkante
  • This issue is blocking
  • This issue is causing unreasonable pain

ConditionalFact attributes are not working when tests are run inside VS 2022 - instead these tests are simply always run.

This was discovered here on the winforms repo, where tests that shouldn't be running were reported as failing.

Its unclear whether this is a VS 2022 issue or if the implementation of ConditionalFact needs to be updated to work under VS 2022

Example repro:

public class MachineSpecificTests
{
    public static bool Is32Bit => IntPtr.Size == 4;
    public static bool Is64Bit => IntPtr.Size == 8;

    [ConditionalFact(nameof(Is32Bit))]
    public void TestIntPtrSize32()
    {
        Assert.Equal(4, IntPtr.Size);
    }

    [ConditionalFact(nameof(Is64Bit))]
    public void TestIntPtrSize64()
    {
        Assert.Equal(8, IntPtr.Size);
    }
}

(The actual tests WinForms uses are here: https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/PARAMTests.cs)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions