docs icon indicating copy to clipboard operation
docs copied to clipboard

In sprint test

Open santhosh-James opened this issue 4 years ago • 3 comments

Is there a way to categorize tests based on sprints dynamically without change the category of test in each sprint?

santhosh-James avatar Jul 06 '20 18:07 santhosh-James

@santhosh-James I'm not sure exactly what you want to do. Can you provide an example and/or some code to make the question more concrete?

You can do something dynamic, if you use parametric tests and pass in TestCaseData (which has a SetCategory method). This will require you to change all your tests to be parametric. Another solution could be to decorate your tests with a custom attribute so you can have the "sprint" logic in one place.

mikkelbu avatar Jul 06 '20 20:07 mikkelbu

Can you please an example of custom attribute ?

On Jul 6, 2020, at 3:42 PM, Mikkel Nylander Bundgaard [email protected] wrote:

 @santhosh-James I'm not sure exactly what you want to do. Can you provide an example and/or some code to make the question more concrete?

You can do something dynamic, if you use parametric tests and pass in TestCaseData (which has a SetCategory method). This will require you to change all your tests to be parametric. Another solution could be to decorate your tests with a custom attribute so you can have the "sprint" logic in one place.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

santhosh-James avatar Jul 06 '20 20:07 santhosh-James

I'm still not sure exactly what you want to do, but you could make an attribute that implementes IApplyToTest - https://github.com/nunit/docs/wiki/IApplyToTest-Interface - like the existing CategoryAttribute - https://github.com/nunit/nunit/blob/master/src/NUnitFramework/framework/Attributes/CategoryAttribute.cs

mikkelbu avatar Jul 06 '20 21:07 mikkelbu

Closed as answered

mikkelbu avatar Feb 22 '23 19:02 mikkelbu