黄瓜+ Maven + TestNG - 测试不运行

时间:2016-09-01 12:09:38

标签: maven testng cucumber-jvm

使用testng通过Maven运行黄瓜功能。测试没有运行,只是在控制台中显示零运行(下面的输出)。

T E S T S

运行TestSuite 测试运行:0,失败:0,错误:0,跳过:0,经过的时间:0.421秒 - 在TestSuite中

结果:

测试运行:0,失败:0,错误:0,跳过:0

[INFO] -------------------------------------------- ----------------------------

[INFO]建立成功

[INFO] -------------------------------------------- ----------------------------

[INFO]总时间:2.507秒

[INFO]完成于:2016年9月1日17:24:45 IST 2016

[INFO]最终记忆:8M / 155M

[INFO] -------------------------------------------- ----------------------------

这是POM.xml                   

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/java/resources/TestSuite.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

    </plugins>

</build>

<dependencies>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.21</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>1.2.4</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.4</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
    </dependency>

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.0</version> 
</dependency>

TestNG xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Test runner">
<test name="Package with subpackages">
    <packages>
        <package name="src.test.java.runner.*"/>
    </packages>
</test> 
</suite>

Runner类代码

import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;


@CucumberOptions (features ="src/test/java/features/NewClientWorkflow.feature",
format = {"pretty", "html:target/cucumber", "json:target/cucumber-  report.json"},
monochrome = true,
glue={"steps"})
public class RunFeaturesTest extends AbstractTestNGCucumberTests{
}

按照以下链接尝试Cucumber + Maven + TestNG组合 https://automatictester.co.uk/2015/06/11/basic-cucumberjvm-selenium-webdriver-test-automation-framework/

1 个答案:

答案 0 :(得分:0)

您要求运行<package name="src.test.java.runner.*"/>

使用maven时,测试的默认文件夹为src/test/java

您没有分享测试的package行,但我无法想象它是以package src.test.java.runner...开头。

尝试使用<package name="runner.*"/>来运行测试。