-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/maiflai/gradle-scalatest …
…into verbosity Conflicts: src/main/groovy/com/github/maiflai/ScalaTestAction.groovy src/test/groovy/com/github/maiflai/ScalaTestActionTest.groovy
- Loading branch information
Showing
10 changed files
with
206 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/groovy/com/github/maiflai/JacocoTestAction.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.maiflai | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.tasks.testing.Test | ||
|
||
class JacocoTestAction implements Action<Test> { | ||
|
||
@Override | ||
void execute(Test task) { | ||
// java.lang.InternalError: Malformed class name when finding by type | ||
def jacoco = task.extensions.findByName('jacoco') | ||
if (jacoco && jacoco.enabled) { | ||
task.jvmArgs jacoco.getAsJvmArg() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
buildscript { | ||
repositories { | ||
// need to get up to the working directory of gradle-plugins build | ||
flatDir dir: "${project.projectDir}/../../../../build/libs" | ||
} | ||
dependencies { | ||
classpath name: 'gradle-scalatest', version: '+' | ||
} | ||
} | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'jacoco' | ||
apply plugin: 'com.github.maiflai.scalatest' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile 'org.scala-lang:scala-library:2.11.6' | ||
testCompile 'org.scalatest:scalatest_2.11:2.2.5' | ||
testRuntime 'org.pegdown:pegdown:1.1.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class Hello { | ||
public String say() { | ||
return "world"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import org.scalatest.FunSuite | ||
|
||
class HelloSpec extends FunSuite { | ||
test("it should cover") { | ||
assert(new Hello().say() === "world") | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/test/groovy/com/github/maiflai/JacocoTestActionIntegrationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.github.maiflai | ||
|
||
import org.gradle.tooling.BuildLauncher | ||
import org.gradle.tooling.GradleConnector | ||
import org.hamcrest.Description | ||
import org.hamcrest.TypeSafeMatcher | ||
import org.junit.Test | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat | ||
|
||
class JacocoTestActionIntegrationTest { | ||
|
||
@Test | ||
public void testReportsAreProduced() throws Exception { | ||
def launcher = setupBuild(new File('src/test/examples/jacoco')) | ||
launcher.forTasks('clean', 'test', 'jacoco').run() | ||
assertThat(new File('src/test/examples/jacoco/build/reports/jacoco/test/html'), isReport) | ||
assertThat(new File('src/test/examples/jacoco/build/reports/tests'), isReport) | ||
} | ||
|
||
protected BuildLauncher setupBuild(File projectRoot) { | ||
return GradleConnector. | ||
newConnector(). | ||
forProjectDirectory(projectRoot). | ||
connect(). | ||
newBuild() | ||
} | ||
|
||
protected TypeSafeMatcher<File> isReport = new TypeSafeMatcher<File>() { | ||
@Override | ||
protected boolean matchesSafely(File file) { | ||
return file.isDirectory() && new File(file, 'index.html').isFile() | ||
} | ||
|
||
@Override | ||
void describeTo(Description description) { | ||
description.appendText('a directory containing index.html') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters