lundi 25 janvier 2021

xUnit - How to select a single Theory when executing from dotnet test CLI

Say I have a test:

  [Theory]
  [InlineData("one")]
  [InlineData("two")]
  public void ShouldSelectSingleTheoryFromDotnetTest(string s)
  {
      Assert.True(true);
  }

I want to execute just the test with Theory data = "one" from the command line using dotnet test.... Is this possible?

I know we can select tests using Traits, but I cannot see how to associate a single trait with each single line of Theory data.

As a workaround I thought maybe I could use the technique of dynamically skipping tests, but still to do that I'd need to read an argument from the command line and can't see how to do that either. One workaround to that, might be to set an environment variable on the command line, then run the tests using the dynamic skipping pattern, where the dynamic skip logic would read the command line argument. But that is very clunky.

Aucun commentaire:

Enregistrer un commentaire