4

I have taken the code example from this link to implement a new Nunit attribute to 'Repeat a test when failing'. I have added this code as a class in my solution.

I then call this new class along side the [Test] attribute:

[Test, RepeatOnFailureAttribute(2)]

But the test does not repeat when failing. I think I need to add this attribute to the Nunit list of attributes. I see the shipped list of attribute's in the XML file nunit.framework, here I have added a new item:

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

But I do not understand how adding this new item into the XML file can be called when we only have the nunit.framework.dll reference assigned to my project.

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

nemesv
  • 138,284
  • 16
  • 416
  • 359
Benny Meade
  • 602
  • 10
  • 25

2 Answers2

1

There is no RepeatOnFailureAttribute in nunit. There is only RepeatAttribute(int count) in nunit framework. Particular Test Case fail or pass depending on your code condition.

  • 1
    I did not say their an was an original attribute in NUnit called RepeatOnFailureAttribute, I said I created one myself using this name. – Benny Meade Sep 14 '12 at 12:52
  • But the question still stands: How to I add my newly created attribute into NUnit so that I can use/call it in my test? – Benny Meade Sep 14 '12 at 12:53
0

Please see this example of custom attribute :

Passing dynamically generated value to NUnit Custom Attribute

If you have created your custom attribute in similar fashion, then I believe you can confirm Failure in "AfterTest". Then If the test has failed you may return a value for the test to be repeated.