maven surefire按目录排除?

问题描述 投票:2回答:1

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

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

<excludes><exclude>**/integration/*</exclude></excludes>

但这导致没有测试运行。然后我为测试添加了一个包含,但仍然没有运行测试:

<includes><include>**/test/*</include></includes>

执行的第一个集成是在src / integration / com下...

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

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

maven unit-testing surefire
1个回答
0
投票

Include / Exclude路径在test'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>
© www.soinside.com 2019 - 2024. All rights reserved.