如何使用Maven在以下位置运行我的黄瓜测试.
源文件夹的src/main/java'和'src/main/resources'包括在每个源文件夹中创建的包'com.testing.TestProject.login'中的步骤定义和功能文件.
我在POM文件中包含了插件和依赖项,但是当我运行maven阶段集成测试时,黄瓜测试没有被执行.
我是Maven的新手.请让我知道要在POM文件中包含什么来运行Maven的黄瓜测试.
这是我的POM文件:
4.0.0 com.testing MyMavenProject 1.0-SNAPSHOT jar MyMavenProject http://maven.apache.org UTF-8 1.1.5 2.39.0 4.11 org.codehaus.mojo exec-maven-plugin 1.2.1 integration-test java info.cukes cucumber-core cucumber.api.cli.Main --format junit:target/cucumber-junit-report/allcukes.xml --format pretty --format html:target/cucumber-html-report --tags @login --glue com/ src/ info.cukes cucumber-core 1.1.5 junit junit ${junit.version} test org.seleniumhq.selenium selenium-java ${selenium.version} info.cukes cucumber-picocontainer ${cucumber-jvm.version} test info.cukes cucumber-junit ${cucumber-jvm.version} test org.testng testng 6.8.7 log4j log4j 1.2.16 commons-logging commons-logging 1.1.3
提前致谢.
从Maven运行Cucumber JVM测试的典型方法是通过提供一个RunCukesTest
从JUnit触发Cucumber 的类来通过JUnit桥接它们.
典型的RunCukesTest类可能如下所示:
package com.testing; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import org.junit.runner.RunWith; @RunWith(Cucumber.class) @CucumberOptions( features = "src/test/resources/features", glue = "com.testing" ) public class RunCukesTest { // NOSONAR SonarLint does not know about @RunWith(Cucumber.class) }
细节说明:
@RunWith(Cucumber.class)
告诉JUnit不要使用它的默认运行程序来运行这个测试类,而是使用Cucumber
JUnit4从JUnit中运行Cucumber的测试运行程序.
@CucumberOptions
告诉Cucumber
在哪里找到它的东西.主要的是:
features
告诉Cucumber
在哪里找到功能文件.
glue
告诉Cucumber
哪些包包含步骤定义.
您的测试类需要以"Test"后缀结束.