Skipping a whole test class in xUnit.net

No – there is no such facility at present, and the last time it was requested it was considered too low value to add,

One quick way of achieving the effect in xUnit is to comment out the public – private classes are not reflected over (obviously it won’t appear on the skip list that way though).

UPDATE: Another way is to put a TraitAttribute on the class and then (assuming you’re using the xunit.console runner) filter it out by running with /-trait traitName. (e.g. you can achieve ExplicitAttribute, some aspects of the BDD frameworky technique of Pending tests and similar semantics that way – of course the big problem is they don’t show up in any reports when using any of these filtering techniques)

UPDATE 2: You can do

const string skip = "Class X disabled";

[Fact(Skip=skip)]
void Test() {}

Then you can change to to const string skip = null to undo the skip. The (dis)advantage of this is that the test is still shown as a Skipped test in the test list, generally with a reason included in the test run report (vs making it private which makes it likely to be forgotten)

Leave a Comment