Clean up TestCommand paraphenalia

This commit is contained in:
Dave Syer
2013-10-08 15:39:37 -04:00
parent 1ce13cc2c2
commit b5f0f97110
13 changed files with 283 additions and 301 deletions

View File

@@ -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());
}
}