ここ

2012-01-04 8 views
-1

が、私はそれが特定の条件に合う場合、私はcontinueingから試験方法を中止したいここ

[TestMethod] 
public static void T1() 
{ 
    if (...) 
     //continue the test 
    else 
     //abort the test from continueing. 
} 

を望むもので実行し続けるから試験方法を中止する方法。

+1

は、あなただけの 'Assert.IsTrue'を使用することはできません使用することはできませんか? –

+1

または反対にAssert.Fail。しかし、これを行う場合、おそらくあなたがあまりにも多くのテストをしているという兆候です。 *テスト*がロジックを必要とするときに特に問題になります。 –

+0

@EtiennedeMartel私は必要なものがはっきりと現れていないかもしれません。 Assert.IsTrueまたはAssert.IsFalseを使用しているだけでは、実際に合格/不合格になっているかテスト環境の問題が原因でテストが合格/不合格であるかどうかはわかりません。 – QianLi

答えて

0
public static void T1() 
    { 
     if (...) 
     //continue the test 
     else 
     { 
      //abort the test from continueing. 
     return; //this will do the trick 
     } 
    } 
1

は、あなただけのreturn文

[TestMethod] 
public static void T1() 
{ 
    if (...) 
    { 
     //continue the test 
    } 
    else 
    { 
     return; 
    } 
}