Search code examples
unit-testingmstestassertxunitassertion

xUnit Equivalent of MSTest's Assert.Inconclusive


What is the xUnit equivalent of the following MSTest code:

Assert.Inconclusive("Reason");

This gives a yellow test result instead of the usual green or red. I want to assert that the test could not be run due to certain conditions and that the test should be re-run after those conditions have been met.


Solution

  • One way is to use the Skip parameter within the Fact or Theory attributes.

    [Fact(Skip = "It's not ready yet")]
    public void ReplaceTokensUnfinished()
    {
        var original = "";
        var expected = "";
        var tokenReplacer = new TokenReplacer();
        var result = tokenReplacer.ReplaceTokens(original, _tokens); // (_tokens is initialised in a constructor)
        Assert.Equal(result, expected);
    }
    

    Which gives this result when run:

    enter image description here