我下载了Quantum Perfecto Starter 模板并将其导入 IntelliJ Ultimate。
如果我运行 maven 测试目标,所有示例测试用例都可以正常执行。我还可以从“testng_all.xml”配置中成功运行测试。但我无法运行单个功能或功能文件。如果我右键单击功能文件并选择运行,我会收到如下错误:
Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file
C:/quantum-starter-project-path/src/main/resources/scenarios/webSearch.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:133)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:104)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:239)
at cucumber.runtime.Runtime.run(Runtime.java:111)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: gherkin.parser.ParseError: Parse error at C:/quantum-starter-project-path/src/main/resources/scenarios/webSearch.feature:45.
Found examples when expecting one of: comment, row, tag. (Current getState: examples).
at gherkin.parser.Parser$Machine.event(Parser.java:207)
at gherkin.parser.Parser.event(Parser.java:159)
at gherkin.parser.Parser.access$100(Parser.java:16)
at gherkin.parser.Parser$Machine.event(Parser.java:215)
at gherkin.parser.Parser.event(Parser.java:159)
at gherkin.parser.Parser.examples(Parser.java:124)
at gherkin.lexer.En.scan(En.java:780)
at gherkin.lexer.I18nLexer.scan(I18nLexer.java:36)
at gherkin.parser.Parser.parse(Parser.java:62)
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:131)
... 7 more
该项目是嵌套在另一个 IntelliJ 项目下的模块。当 Maven 测试发生时,它使用的是嵌入到 IntelliJ 中的 JRE。我已尝试更改功能运行时配置以指向 Maven 使用的相同 JRE,但仍然使用 Maven 测试目标解析和执行的相同测试在我使用运行时失败:功能配置...
文档说这个项目需要 JDK 8。我已经尝试将运行配置指向 JDK 8 和 JDK 11。不过,执行该功能会抛出这个“在期望以下之一时找到示例:评论、行......”错误。
这显然不是功能文件中真正的语法问题,因为 Maven Test 可以很好地解析它。它必须与依赖版本或运行时配置有关...
这是执行 Maven 测试时 IntelliJ 发出的完整命令,该命令成功:
"C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\jbr\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\ghe\ui\apps\lockbox-summary-e2e "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=63112:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar" org.codehaus.classworlds.Launcher -Didea.version2019.3.3 test
这是我运行时 IntelliJ 发出的完整命令:Feature webSearch,它不起作用。它要长得多。这是当我将它指向与 Maven 命令相同的 JRE 时:
"C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\jbr\bin\java.exe" -Dorg.jetbrains.run.directory=C:\quantum-project-starter-path\src\main\resources\scenarios "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=63446:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\quantum-starter-project-path\target\classes;C:\Users\E971227\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\E971227\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\E971227\.m2\repository\info\cukes\cucumber-java\1.2.5\cucumber-java-1.2.5.jar;C:\Users\E971227\.m2\repository\info\cukes\cucumber-core\1.2.5\cucumber-core-1.2.5.jar;C:\Users\E971227\.m2\repository\info\cukes\cucumber-html\0.2.3\cucumber-html-0.2.3.jar;C:\Users\E971227\.m2\repository\info\cukes\cucumber-jvm-deps\1.0.5\cucumber-jvm-deps-1.0.5.jar;C:\Users\E971227\.m2\repository\info\cukes\gherkin\2.12.2\gherkin-2.12.2.jar;C:\Users\E971227\.m2\repository\com\quantum\quantum-support\1.21.2\quantum-support-1.21.2.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\3.141.59\selenium-remote-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\net\bytebuddy\byte-buddy\1.8.15\byte-buddy-1.8.15.jar;C:\Users\E971227\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\E971227\.m2\repository\com\squareup\okhttp3\okhttp\3.11.0\okhttp-3.11.0.jar;C:\Users\E971227\.m2\repository\com\squareup\okio\okio\1.14.0\okio-1.14.0.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar;C:\Users\E971227\.m2\repository\io\appium\java-client\6.1.0\java-client-6.1.0.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-java\3.12.0\selenium-java-3.12.0.jar;C:\Users\E971227\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\E971227\.m2\repository\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;C:\Users\E971227\.m2\repository\com\google\code\gson\gson\2.8.4\gson-2.8.4.jar;C:\Users\E971227\.m2\repository\org\apache\httpcomponents\httpclient\4.5.5\httpclient-4.5.5.jar;C:\Users\E971227\.m2\repository\cglib\cglib\3.2.6\cglib-3.2.6.jar;C:\Users\E971227\.m2\repository\org\ow2\asm\asm\6.0\asm-6.0.jar;C:\Users\E971227\.m2\repository\org\apache\ant\ant\1.9.6\ant-1.9.6.jar;C:\Users\E971227\.m2\repository\org\apache\ant\ant-launcher\1.9.6\ant-launcher-1.9.6.jar;C:\Users\E971227\.m2\repository\commons-validator\commons-validator\1.6\commons-validator-1.6.jar;C:\Users\E971227\.m2\repository\commons-beanutils\commons-beanutils\1.9.2\commons-beanutils-1.9.2.jar;C:\Users\E971227\.m2\repository\commons-digester\commons-digester\1.8.1\commons-digester-1.8.1.jar;C:\Users\E971227\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\E971227\.m2\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar;C:\Users\E971227\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;C:\Users\E971227\.m2\repository\org\springframework\spring-context\5.0.5.RELEASE\spring-context-5.0.5.RELEASE.jar;C:\Users\E971227\.m2\repository\org\springframework\spring-aop\5.0.5.RELEASE\spring-aop-5.0.5.RELEASE.jar;C:\Users\E971227\.m2\repository\org\springframework\spring-beans\5.0.5.RELEASE\spring-beans-5.0.5.RELEASE.jar;C:\Users\E971227\.m2\repository\org\springframework\spring-core\5.0.5.RELEASE\spring-core-5.0.5.RELEASE.jar;C:\Users\E971227\.m2\repository\org\springframework\spring-jcl\5.0.5.RELEASE\spring-jcl-5.0.5.RELEASE.jar;C:\Users\E971227\.m2\repository\org\springframework\spring-expression\5.0.5.RELEASE\spring-expression-5.0.5.RELEASE.jar;C:\Users\E971227\.m2\repository\org\aspectj\aspectjweaver\1.9.1\aspectjweaver-1.9.1.jar;C:\Users\E971227\.m2\repository\org\openpnp\opencv\3.2.0-1\opencv-3.2.0-1.jar;C:\Users\E971227\.m2\repository\org\json\json\20160810\json-20160810.jar;C:\Users\E971227\.m2\repository\com\perfectomobile\http-client\18.3.0.3\http-client-18.3.0.3.jar;C:\Users\E971227\.m2\repository\com\qmetry\qaf\2.1.15\qaf-2.1.15.jar;C:\Users\E971227\.m2\repository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;C:\Users\E971227\.m2\repository\com\sun\jersey\jersey-client\1.19\jersey-client-1.19.jar;C:\Users\E971227\.m2\repository\com\sun\jersey\jersey-core\1.19\jersey-core-1.19.jar;C:\Users\E971227\.m2\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;C:\Users\E971227\.m2\repository\com\sun\jersey\contribs\jersey-multipart\1.19\jersey-multipart-1.19.jar;C:\Users\E971227\.m2\repository\org\jvnet\mimepull\mimepull\1.9.3\mimepull-1.9.3.jar;C:\Users\E971227\.m2\repository\com\sun\jersey\contribs\jersey-apache-client\1.17.1\jersey-apache-client-1.17.1.jar;C:\Users\E971227\.m2\repository\commons-httpclient\commons-httpclient\3.1\commons-httpclient-3.1.jar;C:\Users\E971227\.m2\repository\org\aspectj\aspectjrt\1.8.9\aspectjrt-1.8.9.jar;C:\Users\E971227\.m2\repository\org\aspectj\aspectjtools\1.8.9\aspectjtools-1.8.9.jar;C:\Users\E971227\.m2\repository\net\sourceforge\jexcelapi\jxl\2.6.12\jxl-2.6.12.jar;C:\Users\E971227\.m2\repository\commons-codec\commons-codec\1.8\commons-codec-1.8.jar;C:\Users\E971227\.m2\repository\commons-configuration\commons-configuration\1.7\commons-configuration-1.7.jar;C:\Users\E971227\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\E971227\.m2\repository\com\google\inject\guice\3.0\guice-3.0.jar;C:\Users\E971227\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\E971227\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\E971227\.m2\repository\velocity\velocity-dep\1.4\velocity-dep-1.4.jar;C:\Users\E971227\.m2\repository\com\qmetry\qaf-support\2.1.15\qaf-support-2.1.15.jar;C:\Users\E971227\.m2\repository\com\perfectomobile\pm-webdriver\18.3.0.3\pm-webdriver-18.3.0.3.jar;C:\Users\E971227\.m2\repository\com\perfectomobile\intellij-connector\18.4.0.0\intellij-connector-18.4.0.0.jar;C:\Users\E971227\.m2\repository\com\perfecto\reporting-sdk\reportium-java\2.3\reportium-java-2.3.jar;C:\Users\E971227\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Users\E971227\.m2\repository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-support\3.141.59\selenium-support-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-server\3.141.59\selenium-server-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.141.59\selenium-chrome-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.141.59\selenium-edge-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\3.141.59\selenium-firefox-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\3.141.59\selenium-ie-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.141.59\selenium-opera-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\3.141.59\selenium-safari-driver-3.141.59.jar;C:\Users\E971227\.m2\repository\net\jcip\jcip-annotations\1.0\jcip-annotations-1.0.jar;C:\Users\E971227\.m2\repository\org\seleniumhq\selenium\jetty-repacked\9.4.12.v20180830\jetty-repacked-9.4.12.v20180830.jar;C:\Users\E971227\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;C:\Users\E971227\.m2\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;C:\Users\E971227\.m2\repository\com\google\guava\guava\24.1-jre\guava-24.1-jre.jar;C:\Users\E971227\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\E971227\.m2\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;C:\Users\E971227\.m2\repository\com\google\errorprone\error_prone_annotations\2.1.3\error_prone_annotations-2.1.3.jar;C:\Users\E971227\.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\E971227\.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;C:\Users\E971227\.m2\repository\org\apache\commons\commons-collections4\4.0\commons-collections4-4.0.jar;C:\Users\E971227\.m2\repository\org\testng\testng\6.10\testng-6.10.jar;C:\Users\E971227\.m2\repository\com\beust\jcommander\1.48\jcommander-1.48.jar;C:\Users\E971227\.m2\repository\com\perfecto\reporting-sdk\reportium-testng\2.3\reportium-testng-2.3.jar;C:\Users\E971227\.m2\repository\org\slf4j\slf4j-log4j12\1.7.7\slf4j-log4j12-1.7.7.jar;C:\Users\E971227\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\plugins\junit\lib\junit-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\plugins\cucumber-java\lib\cucumber-jvmFormatter.jar" cucumber.api.cli.Main --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatter --monochrome --glue com.quantum.steps C:/quantum-starter-project-path/src/main/resources/scenarios/webSearch.feature
除上述异常外,此操作失败。搜索错误我只找到实际的语法错误,找不到任何关于这种类型的IDE配置问题。任何方向表示赞赏!