断言不确定和忽略属性 [英] Assert.Inconclusive and IgnoreAttribute

查看:117
本文介绍了断言不确定和忽略属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS Unit测试框架中使用Assert.InconclusiveIgnoreAttribute的正确方法是什么?

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

我们主要将Assert.Inconclusive用于以下测试:

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

  • 尚未实现
  • 以某种方式损坏或不完整=需要进一步关注
  • 当测试体出于任何原因被注释掉

我们这样做是因为:

  • 不确定的测试可以有消息
  • 我们希望在TFS的测试结果中看到这样的测试

我们的问题是Inconclusive测试在TFS和Resharper中都被标记为错误.如果我们改用IgnoreAttribute,我们将在Resharper中看到这些测试,但是MS TestRunner和TFS将完全忽略它们.在TFS和MS测试运行程序中使用IgnoreAttribute就像注释整个测试一样,没有用.

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.

推荐答案

我想您认为不确定"的用法是正确的.

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

尽管以我的经验来看,不确定"更像是警告而不是错误.实际上,它们在TRX中与错误分开报告:

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" />

我通常从< Exec>运行mstest可执行文件. msbuild脚本中执行任务,然后在TRX内窥视以确定它是否应该使构建失败.

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.

这篇关于断言不确定和忽略属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆