I have a (base class) 에 있는 모든 데이터베이스 테스트 나타내는 테스트래, i want to 대체하십시오 있다, 그러나, 이 클래스는 클래스) 에서 연장 " 그룹화할 db-test" doesn& # 39, 나는 이 사실을 안 보일 수 있습니다. 나도 날잡아 이 @Test 주석:
@Test(groups = { "db-test" })
public class DBTestBase {
}
그러나 이 때문에 주석, t 작동합니까 @Test doesn& # 39 에 다양한 방법을 만들어 나가겠다 개의경고 / 오류 검사, eclipse 에서 테스트 때 실행하십시오 튀어 있다.
그래서 비활성화해도 테스트, 따라서 적어도 할당되었는지 그룹화합니다 했다.
@Test(enabled = false, groups = { "db-test" })
public class DBTestBase {
}
그런데 모든 @BeforeTest (및 기타 유사한 주석입니다) 비활성화됨 얻을 수 있다. 이는 물론 난 아니야.
I would like some 클래스용 部门是这样的 주석을 달 수 있는 방법이 있지만, t # 39 는 특정 유형의 그룹화할 doesn& 상당히 테스트래 수 있는 것 같다. 누구 %s/dbase/ext_table. 다른 생각?
답은 오르그리그스테스트래그림소데지레스 통해 맞춤형 :
그러나 사용자 정의 java를 메트로트셀레스 등록할 수 있는 모든 테스트루너 인스턴스입니다 스마르티스트 추가해야 합니다 맞춤형 테스트루너 의해 관리됨, 즉 자신의 합니다.
하지만, 사용자 정의 테스트루너 구축하는 데 필요한 테스트루너파스토리 , , 옵션을 통해 -testrunfactory 등록할 수 있습니다.
하지만 그 고려하지 않습니다 - 테스트런파스토리 테스트래 로 구분된다. 또한 사용자 정의 할 수 있도록 정의하십시오 테스트래 클래스:
그는 자경단원이야. # 39 의 it& 악몽을 되풀이했다. 하지만 역시 코드 과제 도왔으매 비활성화해야 조금 어려운;)
모든 코드 http://math-atlas. sourceforge. 자오네 스니핏 .
평소처럼 kingdome. seattle. 코드 과제:
하나의 자바 클래스 (및 적지 내부 클래스)
it 실행하십시오 (no 인수만 필요)
기본적으로, 내가 만든 a 그룹 주석도 그룹화합니다 테스트 (및 기타) 주석입니다 비슷한 구조를 가진 속성 중 하나이다.
그럼 내가 사용하는 모든 테스트를 보도록 리아노테이션트란스퍼머 그룹산노테이션트란스퍼머 만든 다음, 이 그룹은 추가 및 테스트하려면 클래스뿐만 정의되는 수정되므로 테스트하려면 그룹화할 완벽하게 작동하는 제외 및 포함인지.
새 주석 변압기, 그리고 이 모든 작동됨 사용합니다를 제작식 수정하십시오 완벽하게!
뭐. # 39 한 것이 비 시험 방법, t 단서 조항 doesn& 그룹을 추가합니다. 당시 내가 때문에 다른 어떤 것도 변화시킬 수 있는 주석 변압기 이런게야 있었다 하지만, 내가 어떤 이유로 테스트래 wasn& 짐작이지만요. # 39 에 사용한 것이다. 좋은 방법이 있기 때문에 원하는 대로 전 / 후 주석이 알와이스런 방법 = true. 충분하니라 있는 날.
결과적으로 제가 할 수 있는.
@Groups({ "myGroup1", "myGroup2"})
public class MyTestCase {
@Test
@Groups("aMethodLevelGroup")
public void myTest() {
}
}
그리고 난 변압기 작동합니까 하위 클래스화 한 것도 있고.
실제로 올해 5월 [도움말에서는 나으뇨] (http://testng.org/doc/documentation-main.html # 주석입니다) 이언 리스그룹스 보세요.
How to be, & # 39 에서 실행할 수 있는 모든 테스트 방법을 확장됨 클래스용 그룹화할 aGlobalGroup& # 39. 없이.
첫 번째 쉽게 대답할 수 있습니다.
모든 공공 및 확장됨 클래스 (base class 메서드을 모두 해당 그룹에 적용됩니다.
하지만. 심지어 비사양 테스트래 서버리스 (테스트래 없이 주석) 해당 그룹에 포함될 것이다.
과제: 포함하여 비사양 테스트래 피할 수 있습니다.
@Test(groups = { "aGlobalGroup" })
public class Base {
/**
*
*/
@BeforeClass
public final void setUp() {
System.out.println("Base class: @BeforeClass");
}
/**
* Test not part a 'aGlobalGroup', but still included in that group due to the class annotation. <br />
* Will be executed even if the TestNG class tested is a sub-class.
*/
@Test(groups = { "aLocalGroup" })
public final void aFastTest() {
System.out.println("Base class: Fast test");
}
/**
* Test not part a 'aGlobalGroup', but still included in that group due to the class annotation. <br />
* Will be executed even if the TestNG class tested is a sub-class.
*/
@Test(groups = { "aLocalGroup" })
public final void aSlowTest() {
System.out.println("Base class: Slow test");
//throw new IllegalArgumentException("oups");
}
/**
* Should not be executed. <br />
* Yet the global annotation Test on the class would include it in the TestNG methods...
*/
public final void notATest() {
System.out.println("Base class: NOT a test");
}
/**
* SubClass of a TestNG class. Some of its methods are TestNG methods, other are not. <br />
* The goal is to check if a group specify in the super-class will include methods of this class. <br />
* And to avoid including too much methods, such as public methods not intended to be TestNG methods.
* @author <a href="http://stackoverflow.com/users/6309/vonc">VonC</a>
*/
public static class Extended extends Base
{
/**
* Test not part a 'aGlobalGroup', but still included in that group due to the super-class annotation. <br />
* Will be executed even if the TestNG class tested is a sub-class.
*/
@Test
public final void anExtendedTest() {
System.out.println("Extended class: An Extended test");
}
/**
* Should not be executed. <br />
* Yet the global annotation Test on the class would include it in the TestNG methods...
*/
public final void notAnExtendedTest() {
System.out.println("Extended class: NOT an Extended test");
}
}
유연성을 극대화할 수 있는 방법을 단위로레벨에서 주석 emc. @Test 지정할 수 있습니다.
public class DBTestBase {
@BeforeTest(groups = "db-test")
public void beforeTest() {
System.out.println("Running before test");
}
public void method1() {
Assert.fail(); // this does not run. It does not belong to 'db-test' group.
}
@Test(groups = "db-test")
public void testMethod1() {
Assert.assertTrue(true);
}
}
나는 무언가 빠진 경우, 이는 작동됨 질문이예요 얻을 수 있습니다.