Skip to content
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

Add (ignored) tests for composite builds #132

Closed
wants to merge 2 commits 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ You can find instructions on how to apply the plugin at http://plugins.gradle.or

`gradle checkScoverage` will automatically invoke `reportScoverage` but it won't generate aggregated reports.
In order to check coverage of aggregated reports one should use `gradle checkScoverage aggregateScoverage`.

**Note:** The plugin is not compatible with composite builds. For more information, see [the relevant issue](https://github.com/scoverage/gradle-scoverage/issues/98).

### Configuration

Expand Down
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)
}
}