I'm planning to store all test cases in a excel file with columns indicate test method names, parameters and expected results; however, I found TestCaseSource simply assigns all test cases to every test method. I'm wondering that is there any way I can make NUnit select test cases for methods base on method names I put in the spreadsheet?
Thanks.
There is a way to do this. For example, as you mentioned, you can create a custom attribute.
The idea is to pass name of test to
TestCaseSource
.You can do it by creating
TestCaseSource
as separate class.First,
TestCaseSource
class:Then attribute:
And test:
SpeadSheetTestCaseSource.TestName
is thread static. So you can run tests parallel.