Permalink
Browse files

Added single-test runner addRule

  • Loading branch information...
1 parent d4e37d6 commit 99c481ba665fecaa2457c7abe94d8a1b83ffc4af @matthewmccullough matthewmccullough committed Sep 23, 2011
View
@@ -0,0 +1,18 @@
+apply plugin: 'java'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testCompile 'junit:junit:4.8.2'
+}
+
+tasks.addRule("Rule Usage: testOnly<TestName>") { String taskName ->
+ if (taskName.startsWith("testOnly")) {
+ task(taskName) << {
+ println "Testing: " + (taskName - 'testOnly')
+ //Run the test for this class only (like test single)
+ }
+ }
+}
@@ -0,0 +1,2 @@
+#!/bin/bash
+gradle testOnlyHelloWorld
@@ -0,0 +1,5 @@
+public class HelloWorld {
+ public static void main(String args[]) {
+ System.out.println("hello, world");
+ }
+}
@@ -0,0 +1,10 @@
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class HelloWorldTest1 {
+ @Test
+ public void testHelloWorldPrinting1() {
+ HelloWorld.main(null);
+ assertTrue(true);
+ }
+}
@@ -0,0 +1,10 @@
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class HelloWorldTest2 {
+ @Test
+ public void testHelloWorldPrinting2() {
+ HelloWorld.main(null);
+ assertTrue(true);
+ }
+}

0 comments on commit 99c481b

Please sign in to comment.