Extra test when using InlineAutoData without using InlineAutoData

I have a problem: when using InlineAutoData, so that the test runs with random values. The background is that I am testing a conversion with some input which is required to fulfill the specification. I am not interested in random data.

The next test is performed twice. Once with InlineAutoDataand one with random strings. The test was intentionally simple and crashed while executing random data:

[Theory, GeneralTransferTestConventions]
[InlineAutoData("Allowed", "Allowed")]
public void Testing(string test1Data, string test2Data)
{
    Assert.Equal(test1Data, test2Data);
}

My question is, is there a way to avoid a trial run with random data and how to do it?

+4
source share
1 answer

AutoFixture:

[Theory]
[InlineData("Allowed", "Allowed")]
public void Testing(string test1Data, string test2Data)
{
    Assert.Equal(test1Data, test2Data);
}

xUnit.net .

, , , , , InlineData :

[Theory]
[InlineData("Allowed", "Allowed")]
[InlineData("foo", "foo")]
[InlineData("bar", "bar")]
public void Testing(string test1Data, string test2Data)
{
    Assert.Equal(test1Data, test2Data);
}

"" :

[Fact]
public void Testing()
{
    var test1Data = "Allowed";
    var test2Data = "Allowed";
    Assert.Equal(test1Data, test2Data);
}
+4

Source: https://habr.com/ru/post/1613296/


All Articles