TestNGチュートリアル3–テスト方法を無視

1372 ワード

テストを必要としない方法があれば、@Test注記のenabledをfalseに設定するだけでいいので、TestNGは自動的にこの方法をフィルタします.
package com.fenby.testng;

import org.testng.annotations.Test;

/**
 * TestNG Ignore Test
 * @author fenby.com
 *
 */
public class TestNGTest3 {
 
	@Test(enabled=false)
	public void divisionWithException() {  
	  System.out.println(" ");
	}  
 
}

上記の例ではTestNGはdivisionWithException()メソッドをテストしません.
[TestNG] Running:
  /private/var/folders/43/whhl4z0j2vs4s7s6cxyvt3g40000gp/T/testng-eclipse--1166955065/testng-customsuite.xml


===============================================
    Default test
    Tests run: 0, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 0, Failures: 0, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@40568a8: 4 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@47d69794: 269 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@592bf469: 248 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@5bb5abf7: 34 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@4594cdd: 117 ms

無料のオンラインインタラクティブプログラミング学習プラットフォーム|Fenby.com