It is not possible to universally determine textual order of attributes
based on the metadata alone. Since NUnit tests are driven by the
metadata, and not the source code, there is no way to accomplish what
you want. (Note: it could be done in a framework-dependent, version-
dependent manner, but not across all frameworks and versions)

Further, NUnit expects and allows only _one_ ExpectedExceptionAttribute
on a method. The approach of deriving a new attribute from
ExpectedException does not cause the new attribute to recognized by
NUnit at all.

Charlie

PS: Sorry for the delay, this was inadvertently marked Incomplete some
time ago and I only now re-examined it.


** Changed in: nunitv2
       Status: Incomplete => Won't Fix

-- 
ExpectedException specification
https://bugs.launchpad.net/bugs/532536
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.

Status in NUnit V2 Test Framework: Won't Fix

Bug description:
I subclassed ExpectedException attribute passing to super constructor 
AssertionException type.

Now if I attibute my test method with both my subclass and 
ExpectedException(AssertionException) I get runner and attribute order 
dependent behaviour: 

  - R# runner interpretes all attributes in sequence so a test method body that 
passes is toggled to failure by the first ExpectedException attribute then the 
failure is toggled back to pass by the next ExpectedException attribute. 

  - Nunit 2.5.3 gui-runner seems to interpret just the first one 

for:

    <Test()> <ObservedBehaviour("Code generator produces duplicates.")> 
<ExpectedException(GetType(AssertionException))> _
    Public Sub ObservedBehaviourAfterChangeTest()

yielding:

     Observed behaviour has been changed. Please balance the value of the 
change with compatibility breach costs.
     Originally observed behaviour: Code generator produces duplicates.
     NUnit.Framework.AssertionException was expected

while for

    <Test()> <ExpectedException(GetType(AssertionException))> 
<ObservedBehaviour("Code generator produces duplicates.")> _
    Public Sub ObservedBehaviourAfterChangeTest()

returning:

    NUnit.Framework.AssertionException was expected

The documentation deserves a clarification.



_______________________________________________
Mailing list: https://launchpad.net/~nunit-core
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~nunit-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to