我使用VS2010,我有以下方法調用:使MSTest尊重[Conditional()]屬性?
[Conditional("DEBUG")]
public void VerboseLogging() { }
public void DoSomething() {
VerboseLogging();
Foo();
Bar();
}
然後我對DoSomething
方法,該方法檢查它發出適當的測井單元測試。
[Conditional("DEBUG"), TestMethod()]
public void EnsureVerboseLog() {
DoSomething();
VerifyVerboseLoggingCalled(); // <-- fail in release builds since VerboseLogging() calls get eliminated.
}
看來,MSTest的只能看到TestMethod
並執行它(產生失敗的測試),即使我已經Conditional("DEBUG")
標記,並在釋放模式編譯。
那麼,有沒有辦法排除某些測試,取決於#if
以外的編譯常量?
MSTEST吮吸一個大的比MbUnit的/開羅,是嗎? – 2010-07-01 18:47:28