Search code examples
.netunit-testingresharpermstesttfsbuild

Assert.Inconclusive and IgnoreAttribute


What is the right way to use Assert.Inconclusive and IgnoreAttribute in MS Unit test framework?

We are using Assert.Inconclusive mainly for tests which are:

  • Not implemented yet
  • Somehow broken or incomplete = requires futher attention
  • When test body is for any reason commented out

We are doing this because:

  • Inconclusive test can have message
  • We want to see such tests in test results on TFS

Our problem is that Inconclusive tests are marked as error in both TFS and Resharper. If we use IgnoreAttribute instead we will see these tests in Resharper but MS Test runner and TFS will ignore them at all. Using IgnoreAttribute in TFS and MS Test runner is same like commenting whole test which is useless.


Solution

  • I like to think how you are describing Inconclusive is the proper usage.

    Though in my experience, Inconclusive is treated more like a warning than an error. In fact, they are reported in the TRX separately from errors:

    <TestRun>
       <ResultSummary outcome="Inconclusive">
          <Counters total="1" 
              executed="0" error="0" failed="0" 
              timeout="0" aborted="0" inconclusive="1" 
              passedButRunAborted="0" notRunnable="0" 
              notExecuted="0" disconnected="0" 
              warning="0" passed="0" completed="0" 
              inProgress="0" pending="0" />
    

    I typically run the mstest executable from an <Exec> task in my msbuild script and then peek inside the TRX to determine whether it should fail the build.