小编mr_*_*owl的帖子

Jacoco、Maven 和 TestNG(0 测试覆盖率)

我目前正在尝试使用 Maven 和 TestNG 运行 Jacoco。

我还没有下载/安装任何东西。

我尝试将以下内容添加到我的父 POM(也尝试添加到测试包 POM,但仍然没有结果)

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.3.201306030806</version>
            <configuration>
                <destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</destfile>
                <datafile>${basedir}/target/coverage-reports/jacoco-unit.exec</datafile>
            </configuration>
            <executions>
                <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>
Run Code Online (Sandbox Code Playgroud)

当我执行“mvn clean install”或 mvn package 时,输出将作为“test-output”出现在根文件夹中。我尝试在 Maven 中设置“outputDirectory”,但这没有任何作用。

我遇到的另一个更大的问题是它没有进行任何 testNG 测试。代码覆盖率为0。

有人可以帮忙吗?

java testng maven jacoco

5
推荐指数
1
解决办法
2931
查看次数

尝试将列表转换回数组时出现NullPointerException

我试图将我的列表转换回数组时得到一个NPE.我通过调试,发现我的列表获得了一个空值的额外值.

为什么会发生这种情况,更重要的是如何解决问题?

List<String> attrList = new LinkedList<String>(Arrays.asList(attrArray))

//I loop through and remove unnecessary elements

 attrArray = attrList.toArray(attrArray);

//next line uses attrArray and is throwing NPE.

Here's what I found through debugging,

attrList = [1, 2, 3]

attrArray = [1, 2, 3, null]
Run Code Online (Sandbox Code Playgroud)

java arrays list nullpointerexception

4
推荐指数
1
解决办法
1136
查看次数

标签 统计

java ×2

arrays ×1

jacoco ×1

list ×1

maven ×1

nullpointerexception ×1

testng ×1