Skip to content

Fix the cross (scala) version test (3) #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ task crossScalaVersionFunctionalTest(type: Test) {
group = 'verification'
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
include "**/ScalaMultiModuleCrossVersionTest.*"
include '**/crossversion/*'
forkEvery = 1 // crucial to run every test in its own JVM

testLogging.showStandardStreams = true

Expand All @@ -81,9 +82,7 @@ task functionalTest(type: Test) {
group = 'verification'
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
exclude "**/ScalaMultiModuleCrossVersionTest.*"

testLogging.showStandardStreams = true
exclude '**/crossversion/*'

dependsOn crossScalaVersionFunctionalTest
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scoverage.crossversion;

public class Scala211Test extends ScalaVersionTest {
public Scala211Test() {
super("2_11");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scoverage.crossversion;

public class Scala212Test extends ScalaVersionTest {
public Scala212Test() {
super("2_12");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scoverage.crossversion;

public class Scala213Test extends ScalaVersionTest {
public Scala213Test() {
super("2_13");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.scoverage.crossversion;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Tag;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.scoverage.ScoverageFunctionalTest;
import org.scoverage.ScoveragePlugin;

import java.io.File;

public class ScalaCrossVersionAggregationTest extends ScoverageFunctionalTest {

public ScalaCrossVersionAggregationTest() {
super("scala-multi-module-cross-version");
}

@Test
public void checkAndAggregateAll() throws Exception {

AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
ScoveragePlugin.getAGGREGATE_NAME());

result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("2_11:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("2_12:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("2_13:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("2_11:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("2_12:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("2_13:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getAGGREGATE_NAME());

assertAggregationFilesExist();
assertCoverage(100.0);
}

private void assertAggregationFilesExist() {

Assert.assertTrue(resolve(reportDir(), "index.html").exists());
Assert.assertTrue(resolve(reportDir(), "2_11/src/main/scala/org/hello/World2_11.scala.html").exists());
Assert.assertTrue(resolve(reportDir(), "2_12/src/main/scala/org/hello/World2_12.scala.html").exists());
Assert.assertTrue(resolve(reportDir(), "2_13/src/main/scala/org/hello/World2_13.scala.html").exists());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.scoverage.crossversion;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Tag;
import org.scoverage.ScoverageFunctionalTest;
import org.scoverage.ScoveragePlugin;

import java.io.File;

/**
* This abstract class is used to test each scala version in an individual class.
* It is crucial that each test will be separated into its own class,
* as this is the only way to run these tests in separate JVM processes (via `forkEvery` gradle configuration).
*/
public abstract class ScalaVersionTest extends ScoverageFunctionalTest {

private final String scalaVersion;

public ScalaVersionTest(String scalaVersion) {
super("scala-multi-module-cross-version");
this.scalaVersion = scalaVersion;
}

@Test
public void report() throws Exception {

AssertableBuildResult result = run("clean", ":" + scalaVersion + ":" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded(scalaVersion + ":" + ScoveragePlugin.getREPORT_NAME());

File reportDir = reportDir(projectDir().toPath().resolve(scalaVersion).toFile());
Assert.assertTrue(resolve(reportDir, "index.html").exists());
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/World" + scalaVersion + ".scala.html").exists());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.hello

class World211 {
class World2_11 {

def foo(): String = {
val s = "2" + "11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class World212Suite extends FunSuite {
class World2_11Suite extends FunSuite {

test("foo") {
new World213().foo()
new World2_11().foo()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.hello

class World213 {
class World2_12 {

def foo(): String = {
val s = "2" + "12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class World211Suite extends FunSuite {
class World2_12Suite extends FunSuite {

test("foo") {
new World211().foo()
new World2_12().foo()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.hello

class World212 {
class World2_13 {

def foo(): String = {
val s = "2" + "12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import org.scalatest.junit.JUnitRunner
class World212Suite extends FunSuite {

test("foo") {
new World212().foo()
new World2_13().foo()
}
}