0

So - I have a set of tests that test something - They are sensitive to the current environment - so testing locally tests locally - testing on the build machine tests the deployed server.

However I want to have one method locally that allows me to call the deployed server - but of course I don't want it to run if I run all the local tests - and I don't want it to run on the build machine - I only want it to run when it is the only test being run

ie: I want have something like the following code


    [Fact]
    public void TestA()
    {
    }

    [FactAlone]
    public void TestB()
    {
    }
 
    [Fact]
    public void TestC()
    {
    }

and if I go into resharper or vs test runner, I see that they are all tests - and if I right click and say "run all" - it runs A and C.... but if I right click on B and say run test - I want B to run.

I tried to make a custom fact attribute and a custom IXunitTestCaseDiscoverer... but to make it work I need to know the complete set of tests that will be run - and that wasn't available in the discoverer. I know I could probably do it it if every attribute was mine - but this is a big codebase, and I can't stop people using "Fact", so that's not an option.

at the moment I just comment out the fact, and then uncomment it when I want to run it - which is of course a terrible solution.

Darren Oakey
  • 2,894
  • 3
  • 29
  • 55
  • Does this answer your question? [Can you mark XUnit tests as Explicit?](https://stackoverflow.com/questions/37334245/can-you-mark-xunit-tests-as-explicit) – Ruben Bartelink Oct 15 '22 at 06:53
  • well it's definitely a duplicate of my question - however there are no actual answers - seems nobody has figured out how to do it yet :( – Darren Oakey Oct 16 '22 at 08:41
  • Yep - it's implemented in V3 (which has no timeline you can take a dep on), but there's only very ugly workarounds until then – Ruben Bartelink Oct 16 '22 at 17:46

0 Answers0