如何防止预期的异常中断调试测试运行? [英] How to prevent expected exceptions from breaking the debug test run?

查看:114
本文介绍了如何防止预期的异常中断调试测试运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试模式下运行MSTEST单元测试时,执行将在抛出的每个预期异常中停止。我的测试看起来像这样

When running MSTEST unit tests in debug mode, the execution stops in every expected exception that is thrown. My test looks like this

[TestMethod()]
[ExpectedException(typeof(ArgumentNullException))]
public void ShouldThrowExceptionWhenPassingNull()
{
    object data = null;
    target.CheckNull(data);
}

目标方法如下所示:

public void CheckNull(object data)
{
    if (ReferenceEquals(null, data))
    {
        throw new ArgumentNullException("data");
    }
} // test run breaks here: ArgumentNullException was unhandled by user code


推荐答案

您尝试使用 ctrl-R ctrl-T 而不是 ctrl-R T

EDIT
如果它不是键盘快捷键问题,请查看这个链接。您可以尝试以下内容:

EDIT If it's not a keyboard shortcut issue, then check out this link. You could try the following as noted there:



  1. 为异常类型禁用用户未处理的异常
    你在这里遇到(通过
    调试 - >例外)

  2. 禁用所有异常的断开用户未处理的异常(通过
    调试 - >例外)

  3. 禁用Just My Code


这篇关于如何防止预期的异常中断调试测试运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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