2017-04-20 8 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> 

テストランナークラスは次のようになり、

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

FailedTestRunnerクラストイレ以下のようなKS、

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

TestNG.xmlは、

<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」 特集:テストscrnario 「@ countryname1 @ countryname2」 シナリオ:アプリを考えると起動アプリ は、私は、単一の機能ファイルに複数のタグを持っている を立ち上げています。 –

答えて

0

テンプレートの下に使用してテストランナーとFailedTestRunnerクラスを作成し、例えば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 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(); 
    } 
} 

を一つのブロックのみを使用し、賢明にそれを使用してください

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(); 
    } 
} 
関連する問題