Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在通过surefire插件执行时,有没有一种方法可以排除功能文件包?_Java_Junit_Maven Surefire Plugin_Cucumber Java_Cucumber Junit - Fatal编程技术网

Java 在通过surefire插件执行时,有没有一种方法可以排除功能文件包?

Java 在通过surefire插件执行时,有没有一种方法可以排除功能文件包?,java,junit,maven-surefire-plugin,cucumber-java,cucumber-junit,Java,Junit,Maven Surefire Plugin,Cucumber Java,Cucumber Junit,所以我必须并行执行cucumber文件,但是有些情况下不能并行运行,所以我需要根据包或文件排除它们 我知道.java文件支持这一点,但是我们有类似的.feature文件吗 将黄瓜与JUnit和Surefire插件一起使用 这是一只鹬 <build> <plugins> <plugin> <groupId>org.apache.maven.plug

所以我必须并行执行cucumber文件,但是有些情况下不能并行运行,所以我需要根据包或文件排除它们

我知道.java文件支持这一点,但是我们有类似的.feature文件吗

将黄瓜与JUnit和Surefire插件一起使用

这是一只鹬

    <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.1</version>
                    <configuration>
                        <parallel>all</parallel>
                        <threadCount>3</threadCount>
                        <excludes>
                            <exclude>You can exclude java files from here but not .feature files</exclude>
                        </excludes>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectj.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>

org.apache.maven.plugins
maven surefire插件
2.22.1
全部的
3.
您可以从这里排除java文件,但不能排除.feature文件
org.aspectj
aspectjweaver
${aspectj.version}

您可以使用可以在
maven surefire plugin
配置对象中作为系统属性提供的标记排除功能文件

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <parallel>all</parallel>
                    <threadCount>3</threadCount>
                    <!-- Ignore tag System Property below -->
                    <systemPropertyVariables>
                         <cucumber.filter.tags>not @ignore</cucumber.filter.tags>
                    </systemPropertyVariables>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

org.apache.maven.plugins

)

当与Cucumber和JUnit 5并行执行场景时,您还可以在特定的资源上同步,而不是将应该串行运行的场景放在单独的测试执行中

在执行此操作时,Junit平台将以这样一种方式安排测试,即不应该同时运行的测试不会这样做

若要在特定资源上同步场景,该场景必须是 标记,此标记映射到特定资源的锁。A. 资源由字符串标识,可以使用 读写锁,或读锁

例如,以下标记:

Feature: Exclusive resources

 @reads-and-writes-system-properties
 Scenario: first example
   Given this reads and writes system properties
   When it is executed 
   Then it will not be executed concurrently with the second example

 @reads-system-properties
 Scenario: second example
   Given this reads system properties
   When it is executed
   Then it will not be executed concurrently with the first example
使用此配置:

cumber.execution.exclusive resources.read和write系统属性。read-write=system\u属性 cumber.execution.exclusive resources.reads系统属性。read=system\u属性

第一个场景标记为@reads和writes系统属性 将使用读写锁锁定系统_属性,并且不会 与使用读锁的第二个场景同时执行

作为资源值,您可以定义自己的资源

或使用众所周知的资源,例如:

要使场景独立运行,可以使用
org.junit.platform.engine.support.hierarchy.ExclusiveResource.GLOBAL\u KEY