Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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
maven surefire是否按目录排除?_Maven_Unit Testing_Surefire - Fatal编程技术网

maven surefire是否按目录排除?

maven surefire是否按目录排除?,maven,unit-testing,surefire,Maven,Unit Testing,Surefire,我正在使用maven surefire,需要排除集成测试。我的项目布局是非标准的,我有src/main/com、src/test/com和src/integration/com 默认情况下,当我运行测试目标时,会运行集成测试和单元测试。我想排除集成测试。。。我累了: <excludes><exclude>**/integration/*</exclude></excludes> **/integration/* 但这导致没有测试运行。然后,我为

我正在使用maven surefire,需要排除集成测试。我的项目布局是非标准的,我有src/main/com、src/test/com和src/integration/com

默认情况下,当我运行测试目标时,会运行集成测试和单元测试。我想排除集成测试。。。我累了:

<excludes><exclude>**/integration/*</exclude></excludes>
**/integration/*
但这导致没有测试运行。然后,我为测试添加了一个include,但仍然没有运行任何测试:

<includes><include>**/test/*</include></includes>
**/test/*
执行的第一个集成在src/integration/com下

另外,如果这很重要,那么这个项目是一个子项目,那么这可能会影响要排除的路径吗


关于为什么不能排除这些集成测试的任何指针?

包含/排除路径与测试“src/test/java”的默认配置相对。 您不能有两个测试源,但您应该使用以下替代方法:

<testSourceDirectory>src/test/com</testSourceDirectory>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>TO DO</version>
    <executions>
    <execution>
    <id>add-integration-test-sources</id>
    <phase>generate-test-sources</phase>
    <goals>
        <goal>add-test-source</goal>
    </goals>
    <configuration>
        <sources>
            <source>src/integration/com</source>
        </sources>
    </configuration>
    </execution>
    </executions>
</plugin>
src/test/com
org.codehaus.mojo
构建助手maven插件
做
添加集成测试源
生成测试源
添加测试源
src/integration/com

你不会碰巧在
src/test/com
下有一个名为
integration
的文件夹吗?好主意,我检查了,没有。在src/integration下执行的第一个集成测试。编辑我的问题以添加this。我开始认为这是不可能的,因为所有代码都编译成目标/类,并且测试是从它们的目标/类运行的。这意味着我正在尝试的将不起作用,因为我正在尝试匹配一个无效的目录结构。谢谢您的回复。不过我很困惑。构建助手正在做什么?我想从运行中排除集成测试,并且testSourceDirectory已设置为src/test/*