简体   繁体   English

使用 Azure 构建管道时,从 JaCoCo 中排除多模块 maven 项目中的测试目录

[英]Exclude test directories in multi-module maven projecty from JaCoCo when using Azure build pipeline

This feels like it should be easy, so please help point me in the correct direction.这感觉应该很容易,所以请帮助我指出正确的方向。

I am successfully using maven to build my java project using a Azure Pipeline.我成功地使用 maven 使用 Azure 管道构建我的 java 项目。 I am also successfully getting JaCoCo coverage reports.我也成功地获得了 JaCoCo 报道。

I have a maven project with multiple modules.我有一个包含多个模块的 maven 项目。 Below is a sample project structure.下面是一个示例项目结构。 I want to exclude everything in all the sub src/test/java directories/packages.我想排除所有子 src/test/java 目录/包中的所有内容。

myproject我的项目

mod1
    src/main/java/...
    src/test/java/...
    pom.xml
mod2
    src/main/java/...
    src/test/java/...
    pom.xml
pom.xml

I would have expected something like setting codeCoverageClassFilter to -:*.src.test.java*.* , but none of my variations have worked.我本来期望将codeCoverageClassFilter设置为-:*.src.test.java*.*之类的东西,但是我的所有变体都没有奏效。 What is the correct statement to exclude all these test directories?排除所有这些测试目录的正确说法是什么?

For excluded test add next configuration in pom parent对于排除测试,在 pom parent 中添加下一个配置

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.6</version>
    <configuration>
        <excludes>
            <exclude>com/acme/test/*</exclude>
        </excludes>
    </configuration>
    <executions>
        <!-- prepare agent for measuring integration tests -->
        <execution>
            <id>jacoco-initialize</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM