From 03a7a42552fbcce91d1ec9c82610947f9bc7bada Mon Sep 17 00:00:00 2001 From: Eugene Platonov Date: Sun, 10 Dec 2023 17:14:58 -0500 Subject: [PATCH] Fix reporting and add a minimal set of it-tests --- pom.xml | 62 ++++++-- src/it/integration_tests_parent/pom.xml | 144 ++++++++++++++++++ .../invoker.properties | 1 + .../pom.xml | 45 ++++++ .../src/main/scala/HelloServiceScala.scala | 6 + .../test/scala/HelloServiceScalaTest.scala | 11 ++ .../validate.groovy | 19 +++ .../invoker.properties | 1 + .../pom.xml | 45 ++++++ .../src/main/scala/HelloServiceScala.scala | 6 + .../test/scala/HelloServiceScalaTest.scala | 12 ++ .../validate.groovy | 19 +++ .../invoker.properties | 1 + .../pom.xml | 45 ++++++ .../src/main/scala/HelloServiceScala.scala | 6 + .../test/scala/HelloServiceScalaTest.scala | 11 ++ .../validate.groovy | 19 +++ .../invoker.properties | 1 + .../pom.xml | 45 ++++++ .../src/main/scala/HelloServiceScala.scala | 6 + .../test/scala/HelloServiceScalaTest.scala | 12 ++ .../validate.groovy | 19 +++ .../scoverage/plugin/SCoverageReportMojo.java | 4 +- 23 files changed, 526 insertions(+), 14 deletions(-) create mode 100644 src/it/integration_tests_parent/pom.xml create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_JUnit/invoker.properties create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_JUnit/pom.xml create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/main/scala/HelloServiceScala.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/test/scala/HelloServiceScalaTest.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_JUnit/validate.groovy create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/invoker.properties create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/pom.xml create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/main/scala/HelloServiceScala.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/test/scala/HelloServiceScalaTest.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/validate.groovy create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_JUnit/invoker.properties create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_JUnit/pom.xml create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/main/scala/HelloServiceScala.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/test/scala/HelloServiceScalaTest.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_JUnit/validate.groovy create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/invoker.properties create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/pom.xml create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/main/scala/HelloServiceScala.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/test/scala/HelloServiceScalaTest.scala create mode 100644 src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/validate.groovy diff --git a/pom.xml b/pom.xml index 214fe15f..9c08aa76 100644 --- a/pom.xml +++ b/pom.xml @@ -140,13 +140,13 @@ under the License. org.apache.maven.reporting maven-reporting-api - 3.1.0 + 3.1.1 org.apache.maven.doxia doxia-site-renderer - 1.0 + 1.11.1 @@ -226,7 +226,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - 3.1.0 + 3.6.0 @@ -305,7 +305,7 @@ under the License. org.apache.maven.plugins maven-project-info-reports-plugin - 3.0.0 + 3.5.0 @@ -332,14 +332,7 @@ under the License. org.apache.maven.plugins maven-site-plugin - 3.7.1 - - - org.apache.maven.doxia - doxia-module-markdown - 1.8 - - + 3.12.1 @@ -763,6 +756,51 @@ under the License. + + + integration-tests + + + maven.test.skip + !true + + + + + + maven-invoker-plugin + + + integration-test + integration-tests + + install + run + + + + + ${project.build.directory}/it + false + true + src/it + + **/pom.xml + + + **/off-*/pom.xml + **/off-*/**/pom.xml + **/mi*/pom.xml + **/integration_tests_parent/pom.xml + + setup.groovy + validate.groovy + + + + + + diff --git a/src/it/integration_tests_parent/pom.xml b/src/it/integration_tests_parent/pom.xml new file mode 100644 index 00000000..bf301f3b --- /dev/null +++ b/src/it/integration_tests_parent/pom.xml @@ -0,0 +1,144 @@ + + + + 4.0.0 + + it.scoverage-maven-plugin + integration_tests_parent + 1.0-SNAPSHOT + pom + Scoverage Plugin Integration Tests Parent + Scoverage Plugin Integration Tests Parent + + + UTF-8 + 4.13 + 3.2.17 + + 3.11.0 + 3.1.2 + 4.8.1 + 2.0.0 + 3.5.0 + 3.12.1 + + 2.13 + 12 + ${scala.compat.version}.${scala.minor.version} + + + + + org.scala-lang + scala-library + ${scala.version} + + + + junit + junit + ${junit.version} + test + + + org.scalatest + scalatest_${scala.compat.version} + ${scalatest.version} + test + + + + + src/main/scala + src/test/scala + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler.plugin.version} + + true + true + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + + net.alchim31.maven + scala-maven-plugin + ${scala.plugin.version} + + + default-sbt-compile + + compile + testCompile + + + + + + org.apache.maven.plugins + maven-site-plugin + ${site.plugin.version} + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + org.scalatest + scalatest-maven-plugin + ${scalatest.plugin.version} + + + test + test + + test + + + + + + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${project-info-reports.plugin.version} + + + + index + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + report + + + + + + + + diff --git a/src/it/test_ScalaMavenPlugin_Scala212_JUnit/invoker.properties b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/invoker.properties new file mode 100644 index 00000000..3e51a5a6 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify site -e -ntp \ No newline at end of file diff --git a/src/it/test_ScalaMavenPlugin_Scala212_JUnit/pom.xml b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/pom.xml new file mode 100644 index 00000000..f4683a3a --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + + it.scoverage-maven-plugin + integration_tests_parent + 1.0-SNAPSHOT + ../integration_tests_parent/pom.xml + + + test_ScalaMavenPlugin_Scala212_JUnit + 1.0-SNAPSHOT + jar + Test Scoverage Report using scala-maven-plugin, Scala 2.12 and JUnit + Test Scoverage Report using scala-maven-plugin, Scala 2.12 and JUnit + + + 2.12 + 18 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + @project.groupId@ + @project.artifactId@ + + + + diff --git a/src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/main/scala/HelloServiceScala.scala b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/main/scala/HelloServiceScala.scala new file mode 100644 index 00000000..f946ee95 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/main/scala/HelloServiceScala.scala @@ -0,0 +1,6 @@ +package service + +object HelloServiceScala { + def hello = { "Hello" } + +} diff --git a/src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/test/scala/HelloServiceScalaTest.scala b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/test/scala/HelloServiceScalaTest.scala new file mode 100644 index 00000000..626ff607 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/src/test/scala/HelloServiceScalaTest.scala @@ -0,0 +1,11 @@ +package service + +import org.junit.Test; +import org.junit.Assert.assertEquals + +class HelloServiceScalaTest +{ + @Test + def test1() = assertEquals("Hello", HelloServiceScala.hello) + +} diff --git a/src/it/test_ScalaMavenPlugin_Scala212_JUnit/validate.groovy b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/validate.groovy new file mode 100644 index 00000000..ce78045d --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_JUnit/validate.groovy @@ -0,0 +1,19 @@ +try { + + def logFile = new File(basedir, "build.log") + def lines = logFile.readLines() + assert lines.contains("[INFO] Statement coverage.: 100.00%") + assert lines.contains("[INFO] Branch coverage....: 100.00%") + + def scoverageFile = new File(basedir, "target/scoverage.xml") + assert scoverageFile.exists() + + def reportFile = new File(basedir, "target/site/scoverage/index.html") + assert reportFile.exists() + + return true + +} catch (Throwable e) { + e.printStackTrace() + return false +} diff --git a/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/invoker.properties b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/invoker.properties new file mode 100644 index 00000000..3e51a5a6 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify site -e -ntp \ No newline at end of file diff --git a/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/pom.xml b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/pom.xml new file mode 100644 index 00000000..72837f01 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + + it.scoverage-maven-plugin + integration_tests_parent + 1.0-SNAPSHOT + ../integration_tests_parent/pom.xml + + + test_ScalaMavenPlugin_Scala212_ScalaTest + 1.0-SNAPSHOT + jar + Test Scoverage Report using scala-maven-plugin, Scala 2.12 and ScalaTest + Test Scoverage Report using scala-maven-plugin, Scala 2.12 and ScalaTest + + + 2.12 + 18 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + net.alchim31.maven + scala-maven-plugin + + + org.scalatest + scalatest-maven-plugin + + + @project.groupId@ + @project.artifactId@ + + + + diff --git a/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/main/scala/HelloServiceScala.scala b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/main/scala/HelloServiceScala.scala new file mode 100644 index 00000000..f946ee95 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/main/scala/HelloServiceScala.scala @@ -0,0 +1,6 @@ +package service + +object HelloServiceScala { + def hello = { "Hello" } + +} diff --git a/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/test/scala/HelloServiceScalaTest.scala b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/test/scala/HelloServiceScalaTest.scala new file mode 100644 index 00000000..cf1636c0 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/src/test/scala/HelloServiceScalaTest.scala @@ -0,0 +1,12 @@ +package service + +import org.scalatest.wordspec.AnyWordSpec + +class HelloServiceScalaTest extends AnyWordSpec { + + "HelloService" should { + "say hello" in { + assert(HelloServiceScala.hello == "Hello") + } + } +} diff --git a/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/validate.groovy b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/validate.groovy new file mode 100644 index 00000000..ce78045d --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala212_ScalaTest/validate.groovy @@ -0,0 +1,19 @@ +try { + + def logFile = new File(basedir, "build.log") + def lines = logFile.readLines() + assert lines.contains("[INFO] Statement coverage.: 100.00%") + assert lines.contains("[INFO] Branch coverage....: 100.00%") + + def scoverageFile = new File(basedir, "target/scoverage.xml") + assert scoverageFile.exists() + + def reportFile = new File(basedir, "target/site/scoverage/index.html") + assert reportFile.exists() + + return true + +} catch (Throwable e) { + e.printStackTrace() + return false +} diff --git a/src/it/test_ScalaMavenPlugin_Scala213_JUnit/invoker.properties b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/invoker.properties new file mode 100644 index 00000000..3e51a5a6 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify site -e -ntp \ No newline at end of file diff --git a/src/it/test_ScalaMavenPlugin_Scala213_JUnit/pom.xml b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/pom.xml new file mode 100644 index 00000000..d7ea49fd --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + + it.scoverage-maven-plugin + integration_tests_parent + 1.0-SNAPSHOT + ../integration_tests_parent/pom.xml + + + test_ScalaMavenPlugin_Scala213_JUnit + 1.0-SNAPSHOT + jar + Test Scoverage Report using scala-maven-plugin, Scala 2.13 and JUnit + Test Scoverage Report using scala-maven-plugin, Scala 2.13 and JUnit + + + 2.13 + 12 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + @project.groupId@ + @project.artifactId@ + + + + diff --git a/src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/main/scala/HelloServiceScala.scala b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/main/scala/HelloServiceScala.scala new file mode 100644 index 00000000..f946ee95 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/main/scala/HelloServiceScala.scala @@ -0,0 +1,6 @@ +package service + +object HelloServiceScala { + def hello = { "Hello" } + +} diff --git a/src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/test/scala/HelloServiceScalaTest.scala b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/test/scala/HelloServiceScalaTest.scala new file mode 100644 index 00000000..626ff607 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/src/test/scala/HelloServiceScalaTest.scala @@ -0,0 +1,11 @@ +package service + +import org.junit.Test; +import org.junit.Assert.assertEquals + +class HelloServiceScalaTest +{ + @Test + def test1() = assertEquals("Hello", HelloServiceScala.hello) + +} diff --git a/src/it/test_ScalaMavenPlugin_Scala213_JUnit/validate.groovy b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/validate.groovy new file mode 100644 index 00000000..ce78045d --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_JUnit/validate.groovy @@ -0,0 +1,19 @@ +try { + + def logFile = new File(basedir, "build.log") + def lines = logFile.readLines() + assert lines.contains("[INFO] Statement coverage.: 100.00%") + assert lines.contains("[INFO] Branch coverage....: 100.00%") + + def scoverageFile = new File(basedir, "target/scoverage.xml") + assert scoverageFile.exists() + + def reportFile = new File(basedir, "target/site/scoverage/index.html") + assert reportFile.exists() + + return true + +} catch (Throwable e) { + e.printStackTrace() + return false +} diff --git a/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/invoker.properties b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/invoker.properties new file mode 100644 index 00000000..3e51a5a6 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify site -e -ntp \ No newline at end of file diff --git a/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/pom.xml b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/pom.xml new file mode 100644 index 00000000..71c971fc --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + + it.scoverage-maven-plugin + integration_tests_parent + 1.0-SNAPSHOT + ../integration_tests_parent/pom.xml + + + test_ScalaMavenPlugin_Scala213_ScalaTest + 1.0-SNAPSHOT + jar + Test Scoverage Report using scala-maven-plugin, Scala 2.13 and ScalaTest + Test Scoverage Report using scala-maven-plugin, Scala 2.13 and ScalaTest + + + 2.13 + 12 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + net.alchim31.maven + scala-maven-plugin + + + org.scalatest + scalatest-maven-plugin + + + @project.groupId@ + @project.artifactId@ + + + + diff --git a/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/main/scala/HelloServiceScala.scala b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/main/scala/HelloServiceScala.scala new file mode 100644 index 00000000..f946ee95 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/main/scala/HelloServiceScala.scala @@ -0,0 +1,6 @@ +package service + +object HelloServiceScala { + def hello = { "Hello" } + +} diff --git a/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/test/scala/HelloServiceScalaTest.scala b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/test/scala/HelloServiceScalaTest.scala new file mode 100644 index 00000000..cf1636c0 --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/src/test/scala/HelloServiceScalaTest.scala @@ -0,0 +1,12 @@ +package service + +import org.scalatest.wordspec.AnyWordSpec + +class HelloServiceScalaTest extends AnyWordSpec { + + "HelloService" should { + "say hello" in { + assert(HelloServiceScala.hello == "Hello") + } + } +} diff --git a/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/validate.groovy b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/validate.groovy new file mode 100644 index 00000000..ce78045d --- /dev/null +++ b/src/it/test_ScalaMavenPlugin_Scala213_ScalaTest/validate.groovy @@ -0,0 +1,19 @@ +try { + + def logFile = new File(basedir, "build.log") + def lines = logFile.readLines() + assert lines.contains("[INFO] Statement coverage.: 100.00%") + assert lines.contains("[INFO] Branch coverage....: 100.00%") + + def scoverageFile = new File(basedir, "target/scoverage.xml") + assert scoverageFile.exists() + + def reportFile = new File(basedir, "target/site/scoverage/index.html") + assert reportFile.exists() + + return true + +} catch (Throwable e) { + e.printStackTrace() + return false +} diff --git a/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java b/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java index 855883ee..60bdad1a 100644 --- a/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java +++ b/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java @@ -29,8 +29,7 @@ import java.util.ResourceBundle; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext; -import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.siterenderer.RenderingContext; import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; import org.apache.maven.plugin.AbstractMojo; @@ -43,6 +42,7 @@ import org.apache.maven.reporting.MavenReport; import org.apache.maven.reporting.MavenReportException; +import org.codehaus.doxia.sink.Sink; import org.codehaus.plexus.util.StringUtils; import scala.Option;