Build/Test Issues

xUnit with custom Fact/Theory attribute

Started by isb-ik on 5,134 views

xUnit can be extended by using custom (inherited) attributes for Fact or Theory. There are some examples an the xUnit site for this.
I'm using a WpfTheory attribute (inherited from Theory) to start my tests in a STA thread to be able to create WPF controls in the tests.
It seems that ncrunch does not find this test methods and not identify them as test methods.
Is there an alternative way to mark the methods as tests?
Hi, thanks for posting.

Could you confirm which version of xUnit you're using?

We do support a range of situations with xUnit, though some of the more advanced extensibility features we simply aren't able to handle as they override many of the features of the runner. If you're able to share the code you're using, I can confirm whether this is caused by a defect or whether it is an expected limitation.
Hi, I'm using xUnit 2.4.1.
You can find sample code on the official xunit GitHub repository on https://github.com/xunit/samples.xunit/tree/master/STAExamples.
Thanks for the source link!

Looking at this code, I can confirm that we cannot support this use case.

In this particular instance, the test case itself derives from IXunitTestCase and implements its own custom logic. For NCrunch to be able to work with Xunit, we need to make several assumptions about the structure of the test cases and the manner of their execution. The extensibility shown in this example invalidates our assumptions. I'm sorry, but we can't support this kind of extensibility.

Post a reply

Log in to reply.