用法:java cucumber.api.cli.Main [options] [[FILE | DIR] [:LINE [:LINE] *]] +

时间:2017-04-29 14:30:35

标签: selenium cucumber cucumber-jvm cucumberjs

运行我的功能文件时出现此错误

用法:java cucumber [options] [ [FILE|DIR][:LINE[:LINE]*] ]+

选项:

-g, --glue PATH                    Where glue code (step definitions and hooks) is loaded from.
-f, --format FORMAT[:PATH_OR_URL]  How to format results. Goes to STDOUT unless PATH_OR_URL is specified.
                                   Built-in FORMAT types: junit, html, pretty, progress, json.
                                   FORMAT can also be a fully qualified class name.
-t, --tags TAG_EXPRESSION          Only run scenarios tagged with tags matching TAG_EXPRESSION.
-n, --name REGEXP                  Only run scenarios whose names match REGEXP.
-d, --[no-]-dry-run                Skip execution of glue code.
-m, --[no-]-monochrome             Don't colour terminal output.
-s, --[no-]-strict                 Treat undefined and pending steps as errors.
    --snippets                     Snippet name: underscore, camelcase
    --dotcucumber PATH_OR_URL      Where to write out runtime information. PATH_OR_URL can be a file system
                                   path or a URL.
-v, --version                      Print version.
-h, --help                         You're looking at it.

Exception in thread "main" cucumber.runtime.CucumberException: Unknown option: --plugin
    at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:119)
    at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:50)
    at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:44)
    at cucumber.api.cli.Main.run(Main.java:20)
    at cucumber.api.cli.Main.main(Main.java:16)

我的跑步者课程

package cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

    @RunWith( value = Cucumber.class)
    @CucumberOptions(dryRun = false, strict = true, 
            features="/STAF/src/main/java/CucumberFeature/GmailLoginLogout.feature/",
                                         tags ={"~@/ReCall/src/SeleniumWithCucumber/FbTest.java"})


    public class CucumberRunner {



}

我的专题文件

功能:Gmail登录注销

场景:登录并注销Gmail     鉴于Open gmail     使用valide凭证登录时     然后主页应该来

我的步骤定义

package StepDfination;

import org.openqa.selenium.WebDriver;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class GmailLoginLogout {

    WebDriver driver;
    @Given("^Open gmail$")
    public void Open_gmail(){
        System.out.println("gmailopened ");
    }

    @When("^Login with valide credential$")
    public void Login_with_valide_credential(){
        System.out.println("cridential entered");
    }

    @Then("^Home page should come$")
    public void Home_page_should_come(){
        System.out.println("in home page");
    }

}

3 个答案:

答案 0 :(得分:1)

使用CLI命令将其作为Java程序调用

public static void main(String args[]) {
Main.main(new String[]{"-g", "StepDfination", "-t", "<your tag what you need to test", "/STAF/src/main/java/CucumberFeature/GmailLoginLogout.feature"}); }

正如蚱蜢建议的那样,如果你需要调用它作为TestNG,你需要一个跑步者类。

请注意,您的要素文件位置应该是最后一个。让我知道它是否有帮助!

答案 1 :(得分:0)

看起来你正试图开始。您的步骤只会报告它们已被执行。但是,您的方法看起来非常复杂,并且您收到的错误是您无法理解的。您对Gall's law有疑问。

我建议你从另一个角度出发。从有效的东西开始,然后将其转换成你想要的东西。

克隆Cucumber Team提供的入门项目,然后将其转换为您真正希望拥有的示例。

答案 2 :(得分:0)

尝试使用“ - p”而不是“--plugin” 我发现它与我的类似错误。希望这个日志会有所帮助。

Usage: java cucumber.api.cli.Main [options] [[[FILE|DIR][:LINE[:LINE]*] ]+ | @FILE ]

Options:

  -g, --glue PATH                        Where glue code (step definitions, hooks
                                         and plugins) are loaded from.
  -p, --[add-]plugin PLUGIN[:PATH_OR_URL]
                                         Register a plugin.
                                         Built-in formatter PLUGIN types: junit,
                                         html, pretty, progress, json, usage, rerun,
                                         testng. Built-in summary PLUGIN types:
                                         default_summary, null_summary. PLUGIN can
                                         also be a fully qualified class name, allowing
                                         registration of 3rd party plugins.
                                         --add-plugin does not clobber plugins of that 
                                         type defined from a different source.
  -f, --format FORMAT[:PATH_OR_URL]      Deprecated. Use --plugin instead.
  -t, --tags TAG_EXPRESSION              Only run scenarios tagged with tags matching
                                         TAG_EXPRESSION.
  -n, --name REGEXP                      Only run scenarios whose names match REGEXP.
  -d, --[no-]-dry-run                    Skip execution of glue code.
  -m, --[no-]-monochrome                 Don't colour terminal output.
  -s, --[no-]-strict                     Treat undefined and pending steps as errors.
      --snippets [underscore|camelcase]  Naming convention for generated snippets.
                                         Defaults to underscore.
  -v, --version                          Print version.
  -h, --help                             You're looking at it.
  --i18n LANG                            List keywords for in a particular language
                                         Run with "--i18n help" to see all languages
  --junit,OPTION[,OPTION]*               Pass the OPTION(s) to the JUnit module.
                                         Use --junit,-h or --junit,--help to print the
                                         options of the JUnit module.

Feature path examples:
  <path>                                 Load the files with the extension ".feature"
                                         for the directory <path>
                                         and its sub directories.
  <path>/<name>.feature                  Load the feature file <path>/<name>.feature
                                         from the file system.
  classpath:<path>/<name>.feature        Load the feature file <path>/<name>.feature
                                         from the classpath.
  <path>/<name>.feature:3:9              Load the scenarios on line 3 and line 9 in
                                         the file <path>/<name>.feature.
  @<path>/<file>                         Parse <path>/<file> for feature paths generated
                                         by the rerun formatter.