org.testng.testngexception无法实例化类cucmber-testng错误

时间:2016-08-02 12:05:26

标签: selenium cucumber testng cucumber-jvm cucumber-java

我正在尝试在黄瓜中使用testNG框架。但要低于错误。

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD FAILURE
[INFO] Total time: 8.032 s
[INFO] Finished at: 2016-08-02T16:11:29+05:30
[INFO] Final Memory: 18M/220M    
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project TestCaseAPI: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: There was an error in the forked process
[ERROR] org.testng.TestNGException:
[ERROR] 
[ERROR] Cannot instantiate class com.XXX.automation.feature.RunCuke1Test
[ERROR] at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)

我的跑步者课程如下:

import org.junit.runner.RunWith;
    import cucumber.api.CucumberOptions;
    import cucumber.api.junit.Cucumber;
    import cucumber.api.testng.AbstractTestNGCucumberTests;
    @RunWith(Cucumber.class)
    @CucumberOptions (features = "src/test/resources/feature"
    ,glue="com.XXX.automation.feature"
    ,monochrome=true
    )
    public class RunCuke1Test extends AbstractTestNGCucumberTests {       
    }  

我的testNG.xml如下所示

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test diary">
<classes>
<class name="com.XXX.automation.feature.RunCuke1Test"/> 
</classes> 
</test>
</suite>

我的项目结构如上: enter image description here

我通过Maven运行它

有谁能告诉我这里我做错了什么?

1 个答案:

答案 0 :(得分:1)

我确实重新检查了cuc-testNG maven的依赖性。早些时候我使用的是旧版本。我现在正在使用最新版本,现在我的程序现已成功运行。