我已经创建了一个使用命令行执行cucumber测试的小项目,当我在maven surefire插件中指定我的runner类路径时,我可以使用命令行执行cucumber测试(这里所有的场景都被选中),但当我评论并尝试使用标记选项运行时,我成功地获得了构建,但没有执行任何操作。命令使用mvn测试-Dcucumber。选项=“--tags@Flipkart”
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<!-- <configuration>
<testFailureIgnore>true</testFailureIgnore>
<parallel>methods</parallel>
<threadCount>2</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
<includes>
<exclude>**/*TestRunner.java</exclude>
</includes>
</configuration>-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
package Runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
features= {"src/test/resources/Features"},
glue= {"stepDefinition"})
// tags="@Flipkart",
public class MyTestRunner {
}
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< WebdriverTest:WebdriverTest >---------------------
[INFO] Building WebdriverTest 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from : https://repo.maven.apache.org/maven2/io/cucumber/messages/maven-metadata.xml
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/io/cucumber/messages/maven-metadata.xml (1.9 kB at 771 B/s)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ WebdriverTest ---
[INFO] Deleting C:\Users\user_name\Documents\Parallel\WebdriverTest\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WebdriverTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ WebdriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebdriverTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ WebdriverTest ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 2 source files to C:\Users\user_name\Documents\Parallel\WebdriverTest\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M1:test (default-test) @ WebdriverTest ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ WebdriverTest ---
[INFO] Building jar: C:\Users\user_name\Documents\Parallel\WebdriverTest\target\WebdriverTest-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ WebdriverTest ---
[INFO] Installing C:\Users\user_name\Documents\Parallel\WebdriverTest\target\WebdriverTest-0.0.1-SNAPSHOT.jar to C:\Users\user_name\.m2\repository\WebdriverTest\WebdriverTest\0.0.1-SNAPSHOT\WebdriverTest-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\user_name\Documents\Parallel\WebdriverTest\pom.xml to C:\Users\user_name\.m2\repository\WebdriverTest\WebdriverTest\0.0.1-SNAPSHOT\WebdriverTest-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.196 s
[INFO] Finished at: 2021-05-19T11:56:06+05:30
[INFO] ------------------------------------------------------------------------
回答:对我来说-Dcucumber。options=“--tags@Flipkart”不使用标签(如果有人知道答案,则不知道为什么不使用,请分享)
-Dcucumber。滤器tags=“@Flipkart”在我的Pom中不做任何更改的情况下工作
谢谢你的帮助!
所以我认为你使用的选项不存在。但是有一个“cumber.filter.tags”选项。创建一个maven概要文件,该概要文件只启用带有一个特定标记或过滤器的测试。
示例pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>stackoverflow</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<default.surefire.argline></default.surefire.argline>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*TestRunner*.java</include>
</includes>
<argLine>${default.surefire.argline}</argLine>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>cucumber-flipkart</id>
<properties>
<default.surefire.argline>-Dcucumber.filter.tags="@Flipkart"</default.surefire.argline>
</properties>
</profile>
</profiles>
</project>
要激活配置文件:mvn test-Pcucumber-flipkart
要素文件可能如下所示:
@Flipkart
Feature: Flipper swims north.
Background: Fish needs cold water
Scenario: Flipper goes swimming
Given Flipper is hungry
When he decides to go eating
Then Flipper swims north.
测试运行程序和步骤定义在同一个包中,功能文件在资源中相应的文件夹中。所以跑步者不需要那么多配置:
package com.example;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty", "html:target/cucumber-report.html"})
public class MyTestRunner {
}
这应该可以:)
I使用Processbuilder如下所示: 在方法中,我设置要执行的linux命令,如下所示: 我可以从终端执行相同的命令。
在我的Windows 10机器上安装postgres后,我很难更改与postgres用户关联的密码。我提前道歉,因为我对postgres以及使用它所需的命令非常陌生。 我在下面的文章中引用了批准的答案:致命:用户“postgres”的密码验证失败(postgresql 11和pgAdmin 4) 我被困在台阶上,需要我 我不太明白这一步。我已经采取了以下步骤 打开cmd 运行psql 然后系统向我
我刚开始使用hibernate,并尝试在oracle DB中映射已经创建的表。在下面给定的代码中: 然后成功显示所需的结果。但我想知道例外的原因。寻求帮助。我只知道一些关于hibenate的事情,如果这是一个愚蠢的问题,对不起。 是数据库的名称。这是我的映射:
我使用cucumber1.1.1和运行一个单一的功能有问题。 我可以使用命令包含排除标记 mvn安装-Dcucumber。options=“src/test/resources/featureFiles--tags@NounImport,@~ElementSearch” 当我执行不包含任何标记的特征文件时。类似于mvn安装-Dcucumber。options=“src/test/resources
如何执行cucumber从maven与标签? 我试过的是 mvn清洁测试-Dcucumber。滤器tags=“@TestTag” 我的pom.xmltestng.xml文件,(是否有一种方法可以避免执行脚本from.xml文件,并直接使用场景或功能文件的标记名称?) 使用cucumber.io7.0.0
IM 创建一个 groovy 脚本,用于从 docker 容器执行 SQL 脚本。这是我要执行的命令 当我从终端执行它时,它是有效的,但是当我调用我的groovy脚本来执行那一行时,我得到一个mysql帮助,就像命令不正确一样。 这就是我从groovy执行命令的方式: 有人知道为什么结果不一样或者为什么命令无法识别吗?