Commit b5f0f971 authored by Dave Syer's avatar Dave Syer

Clean up TestCommand paraphenalia

parent 1ce13cc2
...@@ -33,10 +33,6 @@ ...@@ -33,10 +33,6 @@
<groupId>org.codehaus.groovy</groupId> <groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId> <artifactId>groovy</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<!-- Optional --> <!-- Optional -->
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.codehaus.groovy</groupId>
...@@ -48,11 +44,6 @@ ...@@ -48,11 +44,6 @@
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
<!-- Provided (to ensure in m2 repo for @grab to resolve) --> <!-- Provided (to ensure in m2 repo for @grab to resolve) -->
<dependency> <dependency>
<groupId>org.springframework.integration</groupId> <groupId>org.springframework.integration</groupId>
...@@ -87,8 +78,7 @@ ...@@ -87,8 +78,7 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
<resource> <resource>
<directory>testers</directory> <directory>src/main/groovy</directory>
<targetPath>testers</targetPath>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
......
groovy.version: ${groovy.version}
hamcrest.version: ${hamcrest.version}
jetty.version: ${jetty.version}
junit.version: ${junit.version}
reactor.version: ${reactor.version}
spock.version: ${spock.version}
spring.version: ${spring.version}
spring-batch.version: ${spring-batch.version}
spring-boot.version: ${project.version}
spring-rabbit.version: ${spring-rabbit.version}
spring-security.version: ${spring-security.version}
spring-integration.version: ${spring-integration.version}
spring-integration-groovydsl.version: ${spring-integration-groovydsl.version}
tomcat.version: ${tomcat.version}
...@@ -29,97 +29,98 @@ import static org.junit.Assert.assertTrue; ...@@ -29,97 +29,98 @@ import static org.junit.Assert.assertTrue;
/** /**
* Integration tests to exercise the CLI's test command. * Integration tests to exercise the CLI's test command.
* *
* @author Greg Turnquist * @author Greg Turnquist
*/ */
public class TestCommandIntegrationTests { public class TestCommandIntegrationTests {
@BeforeClass @BeforeClass
public static void cleanGrapes() throws Exception { public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary(); GrapesCleaner.cleanIfNecessary();
// System.setProperty("ivy.message.logger.level", "3"); // System.setProperty("ivy.message.logger.level", "3");
} }
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
System.setProperty("disableSpringSnapshotRepos", "true"); System.setProperty("disableSpringSnapshotRepos", "true");
new CleanCommand().run("org.springframework"); new CleanCommand().run("org.springframework");
} }
@After @After
public void teardown() { public void teardown() {
System.clearProperty("disableSpringSnapshotRepos"); System.clearProperty("disableSpringSnapshotRepos");
} }
@Test @Test
public void noTests() throws Throwable { public void noTests() throws Throwable {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/book.groovy"); command.run("samples/book.groovy");
TestResults results = command.getResults(); TestResults results = command.getResults();
assertEquals(0, results.getRunCount()); assertEquals(0, results.getRunCount());
assertEquals(0, results.getFailureCount()); assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful()); assertTrue(results.wasSuccessful());
} }
@Test @Test
public void empty() throws Exception { public void empty() throws Exception {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/empty.groovy"); command.run("samples/empty.groovy");
TestResults results = command.getResults(); TestResults results = command.getResults();
assertEquals(0, results.getRunCount()); assertEquals(0, results.getRunCount());
assertEquals(0, results.getFailureCount()); assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful()); assertTrue(results.wasSuccessful());
} }
@Test(expected = RuntimeException.class) @Test(expected = RuntimeException.class)
public void noFile() throws Exception { public void noFile() throws Exception {
try { try {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/nothing.groovy"); command.run("samples/nothing.groovy");
} catch (RuntimeException e) { }
assertEquals("Can't find testscripts/nothing.groovy", e.getMessage()); catch (RuntimeException e) {
throw e; assertEquals("Can't find samples/nothing.groovy", e.getMessage());
} throw e;
} }
}
@Test @Test
public void appAndTestsInOneFile() throws Exception { public void appAndTestsInOneFile() throws Exception {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/book_and_tests.groovy"); command.run("samples/book_and_tests.groovy");
TestResults results = command.getResults(); TestResults results = command.getResults();
assertEquals(1, results.getRunCount()); assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount()); assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful()); assertTrue(results.wasSuccessful());
} }
@Test @Test
public void appInOneFileTestsInAnotherFile() throws Exception { public void appInOneFileTestsInAnotherFile() throws Exception {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/book.groovy", "testscripts/test.groovy"); command.run("samples/book.groovy", "samples/test.groovy");
TestResults results = command.getResults(); TestResults results = command.getResults();
assertEquals(1, results.getRunCount()); assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount()); assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful()); assertTrue(results.wasSuccessful());
} }
@Test @Test
public void spockTester() throws Exception { public void spockTester() throws Exception {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/spock.groovy"); command.run("samples/spock.groovy");
TestResults results = command.getResults(); TestResults results = command.getResults();
assertEquals(1, results.getRunCount()); assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount()); assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful()); assertTrue(results.wasSuccessful());
} }
@Test @Test
public void spockAndJunitTester() throws Exception { public void spockAndJunitTester() throws Exception {
TestCommand command = new TestCommand(); TestCommand command = new TestCommand();
command.run("testscripts/spock.groovy", "testscripts/book_and_tests.groovy"); command.run("samples/spock.groovy", "samples/book_and_tests.groovy");
TestResults results = command.getResults(); TestResults results = command.getResults();
assertEquals(2, results.getRunCount()); assertEquals(2, results.getRunCount());
assertEquals(0, results.getFailureCount()); assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful()); assertTrue(results.wasSuccessful());
} }
} }
package org.test.command package org.test.command
import joptsimple.OptionSet
@Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r") @Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r")
import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.Git
@Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r") @Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r") @Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r") @Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r") @Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r")
import java.lang.Object
class TestCommand extends OptionHandler { class TestCommand extends OptionHandler {
void options() { void options() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment