2017-04-20 5 views
1

오류 메시지가 아래 얻기에 오이 실패한 기능을 다시 실행하십시오. 일치하지 않는 필터 : [@ test1, @test, 23, 36]. 하나의 유형 [라인, 이름, 태그, 오이에서 다시 실행 옵션을 사용하여 오이에 실패한 기능을 실행 다시하는 동안 한 번

[Utils] [ERROR] [Error] java.lang.IllegalArgumentException: **Inconsistent filters: [@test1, @test, 23, 36]. Only one type [line,name,tag] can be used at once.** 
    at gherkin.formatter.FilterFormatter.detectFilter(FilterFormatter.java:59) 
    at gherkin.formatter.FilterFormatter.<init>(FilterFormatter.java:41) 
    at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:126) 
    at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:104) 
    at cucumber.runtime.model.CucumberFeature.loadFromFileSystemOrClasspath(CucumberFeature.java:75) 
    at cucumber.runtime.model.CucumberFeature.loadFromRerunFile(CucumberFeature.java:67) 
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52) 
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34) 
    at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:239) 
    at cucumber.api.testng.TestNGCucumberRunner.getFeatures(TestNGCucumberRunner.java:85) 
    at cucumber.api.testng.TestNGCucumberRunner.provideFeatures(TestNGCucumberRunner.java:94) 
    at android.consumer.tests.FailedTestRunner.features(FailedTestRunner.java:42) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:55) 
    at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45) 
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:115) 
    at org.testng.internal.Parameters.handleParameters(Parameters.java:509) 
    at org.testng.internal.Invoker.handleParameters(Invoker.java:1308) 
    at org.testng.internal.Invoker.createParameters(Invoker.java:1036) 
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1126) 
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) 
    at org.testng.TestRunner.privateRun(TestRunner.java:744) 
    at org.testng.TestRunner.run(TestRunner.java:602) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:380) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:289) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1226) 
    at org.testng.TestNG.runSuites(TestNG.java:1144) 
    at org.testng.TestNG.run(TestNG.java:1115) 
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:281) 
    at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75) 
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:121) 
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290) 
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242) 
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121) 

의 pom.xml 모양을 사용할 수 있습니다 같은

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://maven.apache.org/POM/4.0.0" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.company</groupId> 
    <artifactId>company</artifactId> 
    <version>0.1-SNAPSHOT</version> 

    <dependencies> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>3.3.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.19.1</version> 
      <type>maven-plugin</type> 
     </dependency> 

     <dependency> 
      <groupId>io.appium</groupId> 
      <artifactId>java-client</artifactId> 
      <version>5.0.0-BETA6</version> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-jvm-deps</artifactId> 
      <version>1.0.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-java</artifactId> 
      <version>1.2.5</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-testng</artifactId> 
      <version>1.2.5</version> 
     </dependency> 

     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.11</version> 
      <!-- <scope>test</scope> --> 
     </dependency> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.1</version> 
     </dependency> 

     <dependency> 
      <groupId>com.google.guava</groupId> 
      <artifactId>guava</artifactId> 
      <version>21.0</version> 
     </dependency> 
    </dependencies>  

    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.6.0</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
        <suiteXmlFiles> 
         <suiteXmlFile>${testngxml}</suiteXmlFile> 
        </suiteXmlFiles> 
        <!-- <groups>${groups}</groups> --> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

의 TestRunner 클래스는

@CucumberOptions(monochrome = true,strict=true,plugin = { "json:target/Result.json","rerun:target/rerun.txt"},features = { 
     "." }, glue = { "stepdefinition" }) 

FailedTestRunner 클래스 화장실처럼 보인다 ,

@CucumberOptions(monochrome = true,strict=true,plugin = { "json:target/Result.json"} ,features = { 
     "@target/rerun.txt" }, glue = { "stepdefinition" }) 

TestNG.xml 포함, 같은 KS 실행

<test name="AndroidConsumerTest"> 
     <parameter name="device" value="FQ79PZKNLJCEGE4H" /> 
     <!-- production - prod ; staging - debug d356be51 7f8dd844 FQ79PZKNLJCEGE4H --> 
     <classes> 
      <class name="TestRunner" /> 
      <class name="FailedTestRunner" /> 
     </classes> 
    </test> 

한 라운드가 성공적으로 완료하고 다시 실행 텍스트 파일이 생성되지만에서 두 번째 주자 클래스에 입력이 텍스트 파일을 제공에 실패한 테스트를 다시 실행하려면 "불일치 필터"오류 메시지가 나타납니다.

+0

rerun.txt 파일 내용을 추가하십시오. –

+0

원래 기능 파일 – Grasshopper

+0

추가 "@regression @smoke는" 특징 : 시나리오 "countryname2 @ COUNTRYNAME1 @"테스트 scrnario : 나는 하나의 기능 파일에 여러 개의 태그를 응용 감안할 때 앱 실행 가 시작됩니다. –

답변

0

템플릿 아래 사용하여의 TestRunner 및 FailedTestRunner 클래스를 만들고

package org.sugat.cucumber.Main; 

import cucumber.runtime.ClassFinder; 
import cucumber.runtime.Runtime; 
import cucumber.runtime.RuntimeOptions; 
import cucumber.runtime.io.MultiLoader; 
import cucumber.runtime.io.ResourceLoader; 
import cucumber.runtime.io.ResourceLoaderClassFinder; 

import java.io.BufferedReader; 
import java.io.File; 
import java.io.FileReader; 
import java.io.IOException; 
import java.util.ArrayList; 
import java.util.List; 

import static java.util.Arrays.asList; 

/** 
* Created by sugat.mankar on 4/20/2017. 
*/ 
public class MyCLIMain { 

    public static void main(String[] args) { 
     List<String> arguments = new ArrayList<String>(); 

     //for running only scenarios with tags use this block 
     arguments.add("path to feature file"); 
     String[] tags = {"@tag1","@tag2","@tag3"}; 
     for (String tag : tags) { 
      arguments.add("--tags"); 
      arguments.add(tag); 
     } 

     //for running only scenario outlines with example line number 
     arguments.add("path to feature file:line number of example"); 

     // for rerun 
     try { 
      if(new File("target/rerun.txt").exists() && new BufferedReader(new FileReader("target/rerun.txt")).readLine() != null) { 
       arguments.add("@target/rerun.txt"); 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     arguments.add("--plugin"); 
     arguments.add("pretty:target/cucumber-pretty.txt"); 
     arguments.add("--plugin"); 
     arguments.add("json:target/Result.json"); 
     arguments.add("--plugin"); 
     arguments.add("rerun:target/rerun.txt"); 
     String[] gluepackages = "org.sugat.steps".split(","); 
     for (String packages : gluepackages) { 
      if (!packages.contains("none")) { 
       arguments.add("--glue"); 
       arguments.add(packages); 
      } 
     } 
     final String[] argv = arguments.toArray(new String[0]); 
     try { 
      byte exitStatus = run(argv, MyCLIMain.class.getClassLoader()); 
      System.exit(exitStatus); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 

    public static byte run(String[] argv, ClassLoader classLoader) throws IOException { 
     RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv))); 
     ResourceLoader resourceLoader = new MultiLoader(classLoader); 
     ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); 
     Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); 
     runtime.run(); 
     return runtime.exitStatus(); 
    } 
} 

예를 들어 TestRunner.java이

과 같이해야합니다 귀하의 요구 사항에 따라 하나의 블록을 사용 현명하게 사용하십시오
package org.sugat.cucumber.Main; 

import cucumber.runtime.ClassFinder; 
import cucumber.runtime.Runtime; 
import cucumber.runtime.RuntimeOptions; 
import cucumber.runtime.io.MultiLoader; 
import cucumber.runtime.io.ResourceLoader; 
import cucumber.runtime.io.ResourceLoaderClassFinder; 

import java.io.BufferedReader; 
import java.io.File; 
import java.io.FileReader; 
import java.io.IOException; 
import java.util.ArrayList; 
import java.util.List; 

import static java.util.Arrays.asList; 

/** 
* Created by sugat.mankar on 4/20/2017. 
*/ 
public class TestRunner{ 

    public static void main(String[] args) { 
     List<String> arguments = new ArrayList<String>(); 

     //BEGIN ********for running only scenarios with tags use this block 
     arguments.add("path to feature file"); 
     String[] tags = {"@tag1","@tag2","@tag3"}; 
     for (String tag : tags) { 
      arguments.add("--tags"); 
      arguments.add(tag); 
     } 
     //END ********for running only scenarios with tags use this block 

     // ********** OR******************* 

     //BEGIN****** for running only scenario outlines with example line number 
     arguments.add("path to feature file:line number of example"); 
     //END****** for running only scenario outlines with example line number 

     arguments.add("--plugin"); 
     arguments.add("pretty:target/cucumber-pretty.txt"); 
     arguments.add("--plugin"); 
     arguments.add("json:target/Result.json"); 
     arguments.add("--plugin"); 
     arguments.add("rerun:target/rerun.txt"); 
     String[] gluepackages = "org.sugat.steps".split(","); 
     for (String packages : gluepackages) { 
      if (!packages.contains("none")) { 
       arguments.add("--glue"); 
       arguments.add(packages); 
      } 
     } 
     final String[] argv = arguments.toArray(new String[0]); 
     try { 
      byte exitStatus = run(argv, TestRunner.class.getClassLoader()); 
      System.exit(exitStatus); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 

    public static byte run(String[] argv, ClassLoader classLoader) throws IOException { 
     RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv))); 
     ResourceLoader resourceLoader = new MultiLoader(classLoader); 
     ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); 
     Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); 
     runtime.run(); 
     return runtime.exitStatus(); 
    } 
} 

FailedTestRunner.java 클래스는 다음과 같아야합니다.

package org.sugat.cucumber.Main; 

import cucumber.runtime.ClassFinder; 
import cucumber.runtime.Runtime; 
import cucumber.runtime.RuntimeOptions; 
import cucumber.runtime.io.MultiLoader; 
import cucumber.runtime.io.ResourceLoader; 
import cucumber.runtime.io.ResourceLoaderClassFinder; 

import java.io.BufferedReader; 
import java.io.File; 
import java.io.FileReader; 
import java.io.IOException; 
import java.util.ArrayList; 
import java.util.List; 

import static java.util.Arrays.asList; 

/** 
* Created by sugat.mankar on 4/20/2017. 
*/ 
public class FailedTestRunner{ 

    public static void main(String[] args) { 
     List<String> arguments = new ArrayList<String>(); 
     // for rerun 
     try { 
      if(new File("target/rerun.txt").exists() && new BufferedReader(new FileReader("target/rerun.txt")).readLine() != null) { 
       arguments.add("@target/rerun.txt"); 
      } else { 
       throw new Exception("Either rerun.txt file is empty or there is no failed test"); 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
     arguments.add("--plugin"); 
     arguments.add("pretty:target/cucumber-pretty.txt"); 
     arguments.add("--plugin"); 
     arguments.add("json:target/Result.json"); 
     arguments.add("--plugin"); 
     arguments.add("rerun:target/rerun.txt"); 
     String[] gluepackages = "org.sugat.steps".split(","); 
     for (String packages : gluepackages) { 
      if (!packages.contains("none")) { 
       arguments.add("--glue"); 
       arguments.add(packages); 
      } 
     } 
     final String[] argv = arguments.toArray(new String[0]); 
     try { 
      byte exitStatus = run(argv, FailedTestRunner.class.getClassLoader()); 
      System.exit(exitStatus); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 

    public static byte run(String[] argv, ClassLoader classLoader) throws IOException { 
     RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv))); 
     ResourceLoader resourceLoader = new MultiLoader(classLoader); 
     ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); 
     Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); 
     runtime.run(); 
     return runtime.exitStatus(); 
    } 
}