Skip to content

Commit

Permalink
Add a test for NPE in #103
Browse files Browse the repository at this point in the history
  • Loading branch information
jozic committed Dec 28, 2023
1 parent e90b566 commit ccbd8d0
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/it/test_report_for_some_submodules/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=clean scoverage:report -e -ntp -pl module01 -pl module02/submodule02_02
16 changes: 16 additions & 0 deletions src/it/test_report_for_some_submodules/module01/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>it.scoverage-maven-plugin</groupId>
<artifactId>test_report_for_some_submodules</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>module01</artifactId>
<name>Test Scoverage report works for specified submodules: Module 1</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pkg01

class HelloService1
{
def hello =
{
"Hello from module 1"
}

}

object HelloService1 extends HelloService1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pkg01

import org.junit.Test;
import org.junit.Assert.assertEquals

class HelloServiceTest
{
@Test
def test1()
{
assertEquals("Hello from module 1", HelloService1.hello)
}

}
23 changes: 23 additions & 0 deletions src/it/test_report_for_some_submodules/module02/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>it.scoverage-maven-plugin</groupId>
<artifactId>test_report_for_some_submodules</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>module02</artifactId>
<packaging>pom</packaging>
<name>Test Scoverage report works for specified submodules: Module 2</name>

<modules>
<module>submodule02_01</module>
<module>submodule02_02</module>
</modules>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>it.scoverage-maven-plugin</groupId>
<artifactId>module02</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>submodule02_01</artifactId>
<name>Test Scoverage report works for specified submodules: SubModule 2_1</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pkg02_01

class HelloService2
{
def hello =
{
"Hello from submodule02_01"
}

}

object HelloService2 extends HelloService2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pkg02_01

import org.junit.Test;
import org.junit.Assert.assertEquals

class HelloServiceTest
{
@Test
def test2()
{
assertEquals("Hello from submodule02_01", HelloService2.hello)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>it.scoverage-maven-plugin</groupId>
<artifactId>module02</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>submodule02_02</artifactId>
<name>Test Scoverage report works for specified submodules: SubModule 2_2</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pkg02_02

class HelloService2
{
def hello =
{
"Hello from submodule02_02"
}

}

object HelloService2 extends HelloService2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pkg02_02

import org.junit.Test;
import org.junit.Assert.assertEquals

class HelloServiceTest
{
@Test
def test2()
{
assertEquals("Hello from submodule02_02", HelloService2.hello)
}

}
65 changes: 65 additions & 0 deletions src/it/test_report_for_some_submodules/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>it.scoverage-maven-plugin</groupId>
<artifactId>integration_tests_parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../integration_tests_parent/pom.xml</relativePath>
</parent>

<artifactId>test_report_for_some_submodules</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Test Scoverage report works for specified submodules</name>
<description>Test Scoverage report works for specified submodules</description>

<properties>
<scala.compat.version>2.13</scala.compat.version>
<scala.minor.version>12</scala.minor.version>
</properties>

<modules>
<module>module01</module>
<module>module02</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<aggregate>true</aggregate> <!-- for aggregated report -->
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<aggregate>true</aggregate> <!-- for aggregated report -->
</configuration>
</plugin>
</plugins>
</reporting>
</project>
14 changes: 14 additions & 0 deletions src/it/test_report_for_some_submodules/validate.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
try {

def aggregatedScoverageFile = new File(basedir, "target/scoverage.xml")
assert aggregatedScoverageFile.exists()

def aggregatedReportFile = new File(basedir, "target/site/scoverage/index.html")
assert aggregatedReportFile.exists()

return true

} catch (Throwable e) {
e.printStackTrace()
return false
}

0 comments on commit ccbd8d0

Please sign in to comment.