Skip to content

ArrayIndexOutOfBoundsException by runnig unit tests with jacoco plugin #799

@BigMacIO

Description

@BigMacIO

Steps to reproduce

JaCoCo version: 0.8.2
Operating system: Win10
Tool integration: Maven/Ant

Expected behaviour

The report generation should be a success

Actual behaviour

BUILD FAILED (the jacoco report generation fails)

A had some DTOs used in my test classes. This DTOs inherit from a BasisDTO class.

When I execute my tests I get the following error log:

[ERROR] Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 1.878 s <<< FAILURE! - in de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest
[ERROR] mapFromEditToEntityDTOCaseLadungstraegerChanged Time elapsed: 1.772 s <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 412
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapFromEditToEntityDTOCaseLadungstraegerChanged(AuftragsContainerEditDTOMapperTest.java:41)

[ERROR] mapEntityToEditDTOCaseSammelladungsIsNull Time elapsed: 0.017 s <<< ERROR!
uk.co.jemos.podam.exceptions.PodamMockeryException
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapEntityToEditDTOCaseSammelladungsIsNull(AuftragsContainerEditDTOMapperTest.java:93)
Caused by: java.lang.reflect.InvocationTargetException
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapEntityToEditDTOCaseSammelladungsIsNull(AuftragsContainerEditDTOMapperTest.java:93)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 789
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapEntityToEditDTOCaseSammelladungsIsNull(AuftragsContainerEditDTOMapperTest.java:93)

[ERROR] mapFromEditToEntityDTOCaseLadungstraegerNotChanged Time elapsed: 0.034 s <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 412
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapFromEditToEntityDTOCaseLadungstraegerNotChanged(AuftragsContainerEditDTOMapperTest.java:64)

[ERROR] mapEntityToEditDTO Time elapsed: 0.017 s <<< ERROR!
uk.co.jemos.podam.exceptions.PodamMockeryException
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapEntityToEditDTO(AuftragsContainerEditDTOMapperTest.java:76)
Caused by: java.lang.reflect.InvocationTargetException
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapEntityToEditDTO(AuftragsContainerEditDTOMapperTest.java:76)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 789
at de.dbh.acfs.auftragsverwaltung.mapper.AuftragsContainerEditDTOMapperTest.mapEntityToEditDTO(AuftragsContainerEditDTOMapperTest.java:76)

...`

my mvn pom looks like this:

<project>
    <build>
          <plugins>`
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.2</version>
                    <executions>
                        <execution>
                            <id>prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <excludes>
                                    <exclude>**/dto/*.*</exclude>
                                    <exclude>**/ejb/*.*</exclude>
                                    <exclude>**/dao/*.*</exclude>
                                    <exclude>de/dbh/acfs/service/*.*</exclude>
                                    <exclude>**/*DTO.*</exclude>
                                    <exclude>**/*DTOBasis.*</exclude>
                                    <exclude>**/*DTOLocationBasis.*</exclude>
                                    <exclude>**/jaxb/*.*</exclude>
                                    <exclude>net/gegis/**/*</exclude>
                                </excludes>
                                <!-- Sets the path to the file which contains the execution data. -->
                                <dataFile>target/jacoco.exec</dataFile>
                                <!-- Sets the output directory for the code coverage report. -->
                                <outputDirectory>target/jacoco-ut</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
        </plugins>
    </build>
</project>

With this config 48 unit tests failed.

When I set reuseForks=false in my surefire plugin config only 21 unit tests failed (Only test classes with more then one methods which use use the same DTO).

Without the jacoco plugin all unit tests run successfully.

It looks as if it is a problem with parallel test execution.

I cannot post my full project. It is very big and contains sensible data. Unfortunately it was not possible to reproduce the error in a small test project. I hope, that you may know a solution for this problem along with my problem description.

Thank you for your support.

Best regards.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions