Search code examples
c#.netunit-testingtestingxunit

Create multiple test scenarios for a method


I'm studying unit tests in dotnet and I have a doubt about the amount of scenarios that is acceptable to be done.

Should I make just one test scenario for my method or should I create several scenarios, store them in a list and iterate them in the Act part, comparing the method's return with the expected response that is already in the list?

I don't know if it would be a good practice to create a list with possible scenarios and their respective results, if anything different from what is expected is returned, which is already stored in the list, then it would be a failure to respond.

What do you think?


Solution

  • From what I can say from my experience is that you should keep it simple and you should avoid doing logic in your test.

    I can really recommend the best practices provided by Microsoft.