I am writing some unit tests and want to make use of Sequential tag, I have found the syntax for delclaring such a test.
[Test, Sequential]
public void TestCalculations(
[Values(10000, 15000, 20000, 25000, 50000)] int salary)
{
}
How are assertions handled when doing tests like sequential/combinatorial with multiple inputs?
Best Wishes
I haven't used these attributes myself, but I'd expect to write the actual test method body exactly as if you were writing it for a single value. Basically you'll only be presented with one value at a time, so just write the code to test that value.
Given the documentation, I don't think Sequential
really makes sense for your example, because you've only got one parameter. It makes sense when you've got multiple parameters, and basically says that the first value for one parameter should be paired with the first value for another parameter, then the second value for each etc, rather than each possible pair being executed. You might use that to give input and expected output, for example:
[Test, Sequential]
public void TestDivisionBy2(
[Values(10, 25, 40)] int input,
[Values(5, 12, 20)] int expectedOutput)
{
Assert.AreEqual(expectedOutput, input / 2);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With