使用TestNG

时间:2016-06-16 06:10:26

标签: java cucumber testng

当我尝试使用TestNG运行一个简单的功能文件时,我收到了一个错误。 请帮忙解决它。我是TestNG的黄瓜新手。

我的测试跑步者档案:

package myCucumberLearningPackage;

import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome=true,
        features="src/myCucumberLearningPackage",
        plugin ={"pretty" , "html:target/cucumber-html-report"}
        )

public class shoppingTestRunner extends AbstractTestNGCucumberTests{    
}

错误:

Error parsing feature file shopping.feature
0 Scenarios
0 Steps
0m0.000s

SKIPPED: feature
         Runs Cucumber Feature
java.lang.RuntimeException: cucumber.runtime.CucumberException: Error parsing feature file shopping.feature
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:162)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:431)
    at org.testng.internal.Invoker.handleParameters(Invoker.java:1335)
    at org.testng.internal.Invoker.createParameters(Invoker.java:1051)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1140)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
    at org.testng.SuiteRunner.run(SuiteRunner.java:254)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: cucumber.runtime.CucumberException: Error parsing feature file shopping.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:235)
    at cucumber.api.testng.TestNGCucumberRunner.getFeatures(TestNGCucumberRunner.java:85)
    at cucumber.api.testng.TestNGCucumberRunner.provideFeatures(TestNGCucumberRunner.java:93)
    at cucumber.api.testng.AbstractTestNGCucumberTests.features(AbstractTestNGCucumberTests.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:136)
    ... 20 more
Caused by: gherkin.lexer.LexingError: Lexing error on line 12: '%_FEATURE_END_%'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.
    at gherkin.lexer.En.scan(En.java:904)
    at gherkin.lexer.I18nLexer.scan(I18nLexer.java:36)
    at gherkin.parser.Parser.parse(Parser.java:62)
    at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:131)
    ... 33 more


===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 1
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 1
===============================================

[TestNG] Time taken by org.testng.reporters.jq.Main@3c5a99da: 16 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 15 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@7dc36524: 0 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@6debcae2: 0 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@23223dd8: 16 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@3cb5cdba: 0 ms

0 个答案:

没有答案