InlineData should be unique within the Theory it belongs to
Test data provided with InlineDataAttribute
is duplicated in other InlineDataAttribute
occurence(s).
Having test data duplicated leads to duplication of test ID which may result in incorrect or unexpected behavior. This usually comes from:
params
defined parametersRemove duplicated InlineDataAttribute
occurrences.
using Xunit;
public class xUnit1025
{
[Theory]
[InlineData(2)]
[InlineData(2)]
public void TestMethod(int x)
{ }
}
using Xunit;
public class xUnit1025
{
[Theory]
[InlineData(2)]
[InlineData(2, 0)]
public void TestMethod(int x, int y = 0)
{ }
}
using Xunit;
public class xUnit1025
{
[Theory]
[InlineData(1, 2, 3)]
[InlineData(new object[] { 1, 2, 3 })]
public void TestMethod(params int[] args)
{ }
}
using Xunit;
public class xUnit1025
{
[Theory]
[InlineData(2)]
public void TestMethod(int x)
{ }
}
using Xunit;
public class xUnit1025
{
[Theory]
[InlineData(2)]
public void TestMethod(int x, int y = 0)
{ }
}
using Xunit;
public class xUnit1025
{
[Theory]
[InlineData(1, 2, 3)]
public void TestMethod(params int[] args)
{ }
}