Nunit Adds Custom Attribute

I have provided sample code from this to implement the new Nunit attribute to retry the test on failure. I added this code as a class in my solution.

Then I call this new class along with the [Test] attribute:

[Test, RepeatOnFailureAttribute(2)]

But the test does not repeat on failure. I think I need to add this attribute to the Nunit attribute list. I see the sent attribute list in the nunit.framework XML file, here I added a new element:

.member. name="T:NUnit.Framework.RepeatOnFailureAttribute"

But I don’t understand how to add this new element to the XML file when we only have the nunit.framework.dll link assigned to my project.

Any help would be greatly appreciated here. Thanks in advance.

+4
source share
2 answers

There is no RepeatOnFailureAttribute attribute in nunit. In the nunit structure, only RepeatAttribute (int count) exists. A specific test case fails or fails depending on your code status.

+2
source

See an example of a user attribute:

Passing a dynamically generated value to a custom NUnit attribute

If you created your own attribute in a similar way, I believe that you can confirm the denial of "AfterTest". Then If the test fails, you can return a value for the retest.

0
source

All Articles