Skip to content

Fix functional tests and add (ignored) tests for composite builds and Scala 2.13 #141

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

Merged
merged 7 commits into from
Jun 23, 2020
Prev Previous commit
Next Next commit
Add an ignored test-case for composite build (ignored since it isn't …
…supported yet)
  • Loading branch information
eyalroth committed Dec 22, 2019
commit d754ede393839c21dbb8241d065057b7cb613f4d
46 changes: 46 additions & 0 deletions src/functionalTest/java/org.scoverage/CompositeBuildTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.scoverage;

import org.junit.Ignore;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Tests are currently ignored as composite builds are not supported yet.
*
* See https://github.com/scoverage/gradle-scoverage/issues/98
*/
public class CompositeBuildTest extends ScoverageFunctionalTest {

public CompositeBuildTest() {
super("composite-build");
}

@Ignore
@Test
public void buildComposite() {

runComposite("clean", "build");
}

@Ignore
@Test
public void reportComposite() {

runComposite("clean", ScoveragePlugin.getREPORT_NAME());
}

private AssertableBuildResult runComposite(String... arguments) {

List<String> fullArguments = new ArrayList<String>();
fullArguments.add("-p");
fullArguments.add("proj1");
fullArguments.add("--include-build");
fullArguments.add("../proj2");
fullArguments.addAll(Arrays.asList(arguments));

return run(fullArguments.toArray(new String[0]));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
id 'org.scoverage'
}

repositories {
jcenter()
}

description = 'a single-module Scala project taking part in a composite build (1)'

apply plugin: 'java'
apply plugin: 'scala'


group "org.composite"
version '1.0'

dependencies {
compile group: 'org.scala-lang', name: 'scala-library', version: "${scalaVersionMajor}.${scalaVersionMinor}.${scalaVersionBuild}"

testRuntime group: 'org.junit.vintage', name: 'junit-vintage-engine', version: junitVersion
testCompile group: 'org.junit.platform', name: 'junit-platform-runner', version: junitPlatformVersion

testCompile group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}", version: scalatestVersion

compile "org.composite:proj2:1.0"
}

test {
useJUnitPlatform()
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.composite.proj1

import org.composite.proj2.Reporter

class Foo {
def bar(): String = "bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.composite.proj1

import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

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

test("bar"){

new Foo().bar()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id 'org.scoverage'
}

repositories {
jcenter()
}

description = 'a single-module Scala project taking part in a composite build (2)'

apply plugin: 'java'
apply plugin: 'scala'


group "org.composite"
version '1.0'

dependencies {
compile group: 'org.scala-lang', name: 'scala-library', version: "${scalaVersionMajor}.${scalaVersionMinor}.${scalaVersionBuild}"

testRuntime group: 'org.junit.vintage', name: 'junit-vintage-engine', version: junitVersion
testCompile group: 'org.junit.platform', name: 'junit-platform-runner', version: junitPlatformVersion

testCompile group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}", version: scalatestVersion
}

test {
useJUnitPlatform()
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.composite.proj2

class Reporter {

def report(rawData: String): Report = {
Report(1,2)
}

class InnerReporter {

def lala(): Unit = {

val x = 1 + 1
x
}
}
}

case class Report(id: Long, count: Int)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.composite.proj2

import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

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

test("report"){

val report = new Reporter().report("x")

assertResult(Report(1, 2))(report)
}
}