Ignore IgnoreAttribute

前端 未结 3 1662
孤独总比滥情好
孤独总比滥情好 2021-01-31 02:43

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

3条回答
  •  一向
    一向 (楼主)
    2021-01-31 02:49

    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.

提交回复
热议问题