忽略IgnoreAttribute [英] Ignore IgnoreAttribute

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

问题描述

我们有MSTest测试,可按小时生产自动运行. 这些测试之一已标记为 [Ignore] 属性,因为它尚未准备好在我们的生产环境中运行.
现在,我想(仅)在我的本地环境上开始该测试,因为我的本地环境已准备好进行该测试.
我尝试通过单击测试代码左侧的ReSharper图标或单击 Unit Test Sessions 窗口中的 Run Selected Tests 图标来运行该测试,但没有任何反应.

We have MSTest tests which automatically run in hourly production. One of these tests is marked with [Ignore] attribute because it is not yet ready to run it in our production environment.
Now I want to start that test (only) on my local environment because my local environment is ready for that test.
I try to run that test by clicking on ReSharper's icon on the left side of test code or by clicking Run Selected Tests icon in Unit Test Sessions window and nothing happens.

我目前通过注释掉[Ignore]行来修复它.但是,现在我需要知道在检入代码之前删除注释字符(//).

I fix it currently by commenting out the [Ignore] line. But now I need to be aware to remove the comment characters (//) before checking-in the code.

还有另一种方式可以临时运行[Ignore]测试吗?

Is there another way to temporarly run an [Ignore]'d test ?

推荐答案

最近,当我遇到诸如此类的问题时,我添加了一个新的,并使用现有调试配置中的设置.然后我转到项目-> MyProjectName属性->生成",确保本地开发人员调试"是所选配置,并将"LOCALDEVBUILD"添加到条件补全符号"中.这允许在编译时使用预处理器指令来切换"代码:

Recently when I have encountered problems such as this, I add a new Build Configuration to the visual studio project named something such as "Local Developer Debug" and use the settings from the existing Debug configuration. Then I go to "Project -> MyProjectName Properties -> Build", make sure "Local Developer Debug" is the selected configuration and add "LOCALDEVBUILD" to "Conditional compliation symbols". This allows for the use of preprocessor directives to 'toggle' code at compile time:

#if (!LOCALDEVBUILD)
    [Ignore]
#endif

不确定这是否是您要寻找的内容...但是它允许您根据构建的目的(通过构建配置)运行/使用特定的代码...使用此方法,您可以离开对于更多的正式"构建,该测试被忽略,但如果您愿意,仍可以在闲暇时执行.

Not sure if this is what you're looking for... but it allows you to run/utilize specific code depending on the intentions of the build (via the build configuration)... With this method you can leave the test ignored for more 'official' builds, but still execute it at your leisure if you so desire.

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

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