2016-10-18 6 views
0

최신 TestNG 버전을 사용하고 있지만 아직 작성된 순서대로 테스트 사례를 실행할 수 없습니다 (우선 순위 주석 태그는 사용하지 않음).우선 순위를 사용하지 않고 TestNG에서 실행 순서

enter image description here

import org.testng.annotations.Test; 
public class NewTest { 
@Test 
public void b() { 
    System.out.println("inside b method"); 
} 
@Test 
public void a() { 
System.out.println("inside a method"); 
} 
} 

또한 IMethodInterceptor하지만 여전히 이동을 사용했다.

testng.xml에서

도 추가 청취자 :

<listeners> 
<listener class-name="testngdemo.PriorityInterceptor" /> 
</listeners> 

하지만 여전히 다음지고 출력

inside a method 
inside b method 

우선 순위 인터페이스 : 당신은 무엇을하려고하는 것은 정말 분명하지 않다

import java.lang.annotation.Retention; 
import java.lang.annotation.Target; 
import static java.lang.annotation.ElementType.METHOD; 
import static java.lang.annotation.ElementType.TYPE; 

@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) 
@Target({METHOD, TYPE}) 
public @interface Priority { int value() default 0; } 
+0

http://stackoverflow.com/questions/ 2669576 /이 접근법에있어 무엇이 잘못 되었나요? –

+0

@ImeshaSudasingha jacobcs에서 언급 한 것과 같은 절차를 따랐지만 여전히 알파벳순으로 실행 중입니다. –

+0

@ImeshaSudasingha 메소드 ID를 얻지 만 실행되지 않습니다. 우선이다 MethodInstance 방법 NewTest.b =() PRI : 0 예 : [email protected]] [email protected]] 방법 B 결과 : 0 –

답변

0

하지만, ab 사이의 종속성이있는 경우 단지 the dependsOnMethods feature를 사용

public class NewTest { 
    @Test 
    public void b() { 
    System.out.println("inside b method"); 
    } 

    @Test(dependsOnMethods = { "b" }) 
    public void a() { 
    System.out.println("inside a method"); 
    } 
} 
+0

I 모든 종속성이 없다. 지금까지 나는 testng이 알파벳 순서로 메소드를 실행한다는 것을 알고있다. (내가 틀렸다면 나를 바로 잡아라.) –

+0

작성된 순서에 따라 테스트 케이스를 실행하고 싶습니다. testng 우선 순위 주석 태그를 사용하지 않고. –

+0

응용 프로그램을 어떻게 실행합니까? testng xml을 사용하거나 eclipse/intellij testng 플러그인을 사용하고 있습니까? 플러그인을 사용하지 않는 경우 이전 대답에서 제공된대로 순서대로 테스트 메소드를 추가하십시오. –

1

당신이 TestNG를 XML의 테스트 케이스를 실행하는 경우는 다음과 같이 원하는 순서대로 시험 방법을 포함한다 :

<classes> 

    .... 
     .... 
     <class name="Fully qualified class name without extension"> 
      <methods> 
      <include name="method_1" /> 
      <include name="method_1" /> 
      ..... 
      ..... 
      <include name="method_N" /> 
      </methods> 
     </class> 

     <class name="test.Test2" /> 
    .... 
    .... 

</classes> 
+0

제안 해 주셔서 감사합니다 :) .... 실제로 작동하지만 20-30 가지 이상의 방법이 있다면 어색해 보일 것입니다. –

관련 문제