Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would avoid externalising skipping tests (i.e. a config/command file if it's possible). This somewhat goes against making the tests easy to run and trustworthy. Making the tests ignored in code is the safest approach when other people start to get involved.</p> <p>I could see a number of options, here are two that involve modification of existing code.</p> <h3>Option 1 - Most intrusive, compile time platform detection</h3> <p>In the VS Solution, define another configuration that defines a precompiler flag <code>MONOWIN</code> (just so that it's explicitly a flag the says that it is for code compiled on Windows for use on Mono).</p> <p>Then define an attribute that will make the test ignored when compiled for Mono:</p> <pre><code>public class IgnoreOnMonoFactAttribute : FactAttribute { #if MONOWIN public IgnoreOnMonoFactAttribute() { Skip = "Ignored on Mono"; } #endif } </code></pre> <p>It's actually hard to find any advantages to this method as it involves mocking with the original solution and adds another confiration that needs to be supported.</p> <h3>Option 2 - somewhat intrusive - runtime platform detection</h3> <p>Here is a similar solution to option1, except no separate configuration is required:</p> <pre><code>public class IgnoreOnMonoFactAttribute : FactAttribute { public IgnoreOnMonoFactAttribute() { if(IsRunningOnMono()) { Skip = "Ignored on Mono"; } } /// &lt;summary&gt; /// Determine if runtime is Mono. /// Taken from http://stackoverflow.com/questions/721161 /// &lt;/summary&gt; /// &lt;returns&gt;True if being executed in Mono, false otherwise.&lt;/returns&gt; public static bool IsRunningOnMono() { return Type.GetType("Mono.Runtime") != null; } } </code></pre> <h3>Note 1</h3> <p>xUnit runner will run a method twice if it is marked with <code>[Fact]</code> and <code>[IgnoreOnMonoFact]</code>. (CodeRush doesn't do that, in this case I assume xUnit is correct). This means that any tests methods must have <code>[Fact]</code> replaced with <code>[IgnoreOnMonoFact]</code></p> <h3>Note 2</h3> <p>CodeRush test runner still ran the <code>[IgnoreOnMonoFact]</code> test, but it did ignore the <code>[Fact(Skip="reason")]</code> test. I assume it is due to CodeRush reflecting xUnit and not actually running it with the aid of xUnit libraries. This works fine with xUnit runner.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload