Skip to content

Commit

Permalink
Merge pull request #24 from szpak/issues/23-add-tests
Browse files Browse the repository at this point in the history
Basic functional tests
  • Loading branch information
marcingrzejszczak committed Mar 2, 2015
2 parents e62b8bc + 66f0166 commit 5370898
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
jdk:
- oraclejdk8
- oraclejdk7
- openjdk6

script:
- ./gradlew clean build
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ dependencies {
}
testRuntime 'cglib:cglib-nodep:2.2.2'
testRuntime 'org.objenesis:objenesis:1.2'

testCompile('com.netflix.nebula:nebula-test:2.0.5') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
}

bintrayUpload.dependsOn 'build'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ class TestProfilerPlugin implements Plugin<Project> {
task.dependsOn(JavaPlugin.TEST_TASK_NAME)
task.conventionMapping.with {
testProfilerPluginExtension = { extension }
mergedTestProfilingSummaryDir = { new File(project.rootDir, extension.mergedSummaryDir) }
mergedTestProfilingSummaryDir = { mergedTestProfilingSummaryDir(project, extension) }
}
}

private File mergedTestProfilingSummaryDir(Project project, TestProfilerPluginExtension extension) {
File mergedTestProfilingSummaryDir = new File(project.rootDir, extension.mergedSummaryDir)
mergedTestProfilingSummaryDir.mkdirs()
return mergedTestProfilingSummaryDir
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.blogspot.toomuchcoding.testprofiler

import nebula.test.IntegrationSpec
import nebula.test.functional.ExecutionResult

class BasicFuncSpec extends IntegrationSpec {

void setup() {
fork = true //to make stdout assertion work with Gradle 2.x - http://forums.gradle.org/gradle/topics/unable-to-catch-stdout-stderr-when-using-tooling-api-i-gradle-2-x#reply_15357743
}

def "should do something"() {
given:
copyResources("sample_project", "")
when:
ExecutionResult result = runTasksSuccessfully("profileTests")
then:
result.standardOutput.contains("Your tests report is ready")
and:
fileExists("reports/test_profiling/summary.csv") //TODO: Put reports in project.buildDir
}
}
19 changes: 19 additions & 0 deletions src/test/resources/sample_project/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apply plugin: 'groovy'
apply plugin: 'com.blogspot.toomuchcoding.testprofiler'

repositories {
mavenLocal()
jcenter()
}

dependencies {
compile "org.codehaus.groovy:groovy-all:2.3.9"
compile "org.slf4j:slf4j-api:1.7.10"

testRuntime 'org.slf4j:slf4j-log4j12:1.7.10'
testCompile('org.spockframework:spock-core:0.7-groovy-2.0') {
exclude module: 'groovy-all'
}
testRuntime 'cglib:cglib-nodep:2.2.2'
testRuntime 'org.objenesis:objenesis:1.2'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package foo;

public class Calculator {
int add(int first, int second) {
return first + second;
}

int subtract(int first, int second) {
return first - second;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package foo;

import org.junit.Test;

public class CalculatorTest {

@Test
public void should_add_two_numbers() {
assert 5 == new foo.Calculator().add(2, 3);
}

@Test
public void should_subtract_a_number_from_another() {
assert 2 == new foo.Calculator().subtract(3, 1);
}
}

0 comments on commit 5370898

Please sign in to comment.