Commit b5f0f971 authored by Dave Syer's avatar Dave Syer

Clean up TestCommand paraphenalia

parent 1ce13cc2
......@@ -33,10 +33,6 @@
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<!-- Optional -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
......@@ -48,11 +44,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
<!-- Provided (to ensure in m2 repo for @grab to resolve) -->
<dependency>
<groupId>org.springframework.integration</groupId>
......@@ -87,8 +78,7 @@
<filtering>true</filtering>
</resource>
<resource>
<directory>testers</directory>
<targetPath>testers</targetPath>
<directory>src/main/groovy</directory>
</resource>
</resources>
<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;
/**
* Integration tests to exercise the CLI's test command.
*
*
* @author Greg Turnquist
*/
public class TestCommandIntegrationTests {
@BeforeClass
public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary();
// System.setProperty("ivy.message.logger.level", "3");
}
@BeforeClass
public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary();
// System.setProperty("ivy.message.logger.level", "3");
}
@Before
public void setup() throws Exception {
System.setProperty("disableSpringSnapshotRepos", "true");
new CleanCommand().run("org.springframework");
}
@Before
public void setup() throws Exception {
System.setProperty("disableSpringSnapshotRepos", "true");
new CleanCommand().run("org.springframework");
}
@After
public void teardown() {
System.clearProperty("disableSpringSnapshotRepos");
}
@After
public void teardown() {
System.clearProperty("disableSpringSnapshotRepos");
}
@Test
public void noTests() throws Throwable {
TestCommand command = new TestCommand();
command.run("testscripts/book.groovy");
TestResults results = command.getResults();
assertEquals(0, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void noTests() throws Throwable {
TestCommand command = new TestCommand();
command.run("samples/book.groovy");
TestResults results = command.getResults();
assertEquals(0, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void empty() throws Exception {
TestCommand command = new TestCommand();
command.run("testscripts/empty.groovy");
TestResults results = command.getResults();
assertEquals(0, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void empty() throws Exception {
TestCommand command = new TestCommand();
command.run("samples/empty.groovy");
TestResults results = command.getResults();
assertEquals(0, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test(expected = RuntimeException.class)
public void noFile() throws Exception {
try {
TestCommand command = new TestCommand();
command.run("testscripts/nothing.groovy");
} catch (RuntimeException e) {
assertEquals("Can't find testscripts/nothing.groovy", e.getMessage());
throw e;
}
}
@Test(expected = RuntimeException.class)
public void noFile() throws Exception {
try {
TestCommand command = new TestCommand();
command.run("samples/nothing.groovy");
}
catch (RuntimeException e) {
assertEquals("Can't find samples/nothing.groovy", e.getMessage());
throw e;
}
}
@Test
public void appAndTestsInOneFile() throws Exception {
TestCommand command = new TestCommand();
command.run("testscripts/book_and_tests.groovy");
TestResults results = command.getResults();
assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void appAndTestsInOneFile() throws Exception {
TestCommand command = new TestCommand();
command.run("samples/book_and_tests.groovy");
TestResults results = command.getResults();
assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void appInOneFileTestsInAnotherFile() throws Exception {
TestCommand command = new TestCommand();
command.run("testscripts/book.groovy", "testscripts/test.groovy");
TestResults results = command.getResults();
assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void appInOneFileTestsInAnotherFile() throws Exception {
TestCommand command = new TestCommand();
command.run("samples/book.groovy", "samples/test.groovy");
TestResults results = command.getResults();
assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void spockTester() throws Exception {
TestCommand command = new TestCommand();
command.run("testscripts/spock.groovy");
TestResults results = command.getResults();
assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void spockTester() throws Exception {
TestCommand command = new TestCommand();
command.run("samples/spock.groovy");
TestResults results = command.getResults();
assertEquals(1, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void spockAndJunitTester() throws Exception {
TestCommand command = new TestCommand();
command.run("testscripts/spock.groovy", "testscripts/book_and_tests.groovy");
TestResults results = command.getResults();
assertEquals(2, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
@Test
public void spockAndJunitTester() throws Exception {
TestCommand command = new TestCommand();
command.run("samples/spock.groovy", "samples/book_and_tests.groovy");
TestResults results = command.getResults();
assertEquals(2, results.getRunCount());
assertEquals(0, results.getFailureCount());
assertTrue(results.wasSuccessful());
}
}
package org.test.command
import joptsimple.OptionSet
@Grab("org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r")
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 {
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