Improve speed of spring-test build
- Now excluding *TestSuite classes from the JUnit test task. - Renamed SpringJUnit4SuiteTests to SpringJUnit4TestSuite so that it is no longer executed in the build. - Reduced sleep time in various timing related tests.
This commit is contained in:
parent
c1fe3c056a
commit
5b147bfba8
|
|
@ -655,7 +655,7 @@ project("spring-test") {
|
|||
dependsOn testNG
|
||||
useJUnit()
|
||||
// "TestCase" classes are run by other test classes, not the build.
|
||||
exclude "**/*TestCase.class"
|
||||
exclude(["**/*TestCase.class", "**/*TestSuite.class"])
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.JUnit4;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
|
@ -179,9 +180,14 @@ public class ClassLevelDirtiesContextTests {
|
|||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestExecutionListeners( { DependencyInjectionTestExecutionListener.class,
|
||||
DirtiesContextTestExecutionListener.class })
|
||||
@ContextConfiguration("/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml")
|
||||
@ContextConfiguration
|
||||
public static abstract class BaseTestCase {
|
||||
|
||||
@Configuration
|
||||
static class Config {
|
||||
/* no beans */
|
||||
}
|
||||
|
||||
@Autowired
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -156,34 +156,34 @@ public class RepeatedSpringRunnerTests {
|
|||
public static final class TimedRepeatedTestCase extends AbstractRepeatedTestCase {
|
||||
|
||||
@Test
|
||||
@Timed(millis = 10000)
|
||||
@Timed(millis = 1000)
|
||||
@Repeat(5)
|
||||
public void repeatedFiveTimesButDoesNotExceedTimeout() throws Exception {
|
||||
incrementInvocationCount();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timed(millis = 100)
|
||||
@Timed(millis = 10)
|
||||
@Repeat(1)
|
||||
public void singleRepetitionExceedsTimeout() throws Exception {
|
||||
incrementInvocationCount();
|
||||
Thread.sleep(250);
|
||||
Thread.sleep(15);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timed(millis = 200)
|
||||
@Timed(millis = 20)
|
||||
@Repeat(4)
|
||||
public void firstRepetitionOfManyExceedsTimeout() throws Exception {
|
||||
incrementInvocationCount();
|
||||
Thread.sleep(250);
|
||||
Thread.sleep(25);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timed(millis = 1000)
|
||||
@Timed(millis = 100)
|
||||
@Repeat(10)
|
||||
public void collectiveRepetitionsExceedTimeout() throws Exception {
|
||||
incrementInvocationCount();
|
||||
Thread.sleep(150);
|
||||
Thread.sleep(11);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -42,15 +42,16 @@ import org.springframework.test.context.junit4.profile.xml.DevProfileXmlConfigTe
|
|||
|
||||
/**
|
||||
* JUnit test suite for tests involving {@link SpringJUnit4ClassRunner} and the
|
||||
* <em>Spring TestContext Framework</em>.
|
||||
* <em>Spring TestContext Framework</em>; only intended to be run manually as a
|
||||
* convenience.
|
||||
*
|
||||
* <p>This test suite serves a dual purpose of verifying that tests run with
|
||||
* {@link SpringJUnit4ClassRunner} can be used in conjunction with JUnit's
|
||||
* {@link Suite} runner.
|
||||
*
|
||||
* <p>Note that tests included in this suite will be executed at least twice if
|
||||
* run from an automated build process, test runner, etc. that is configured to
|
||||
* run tests based on a "*Tests.class" pattern match.
|
||||
* run from an automated build process, test runner, etc. that is not configured
|
||||
* to exclude tests based on a "*TestSuite.class" pattern match.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
|
|
@ -104,6 +105,6 @@ StandardJUnit4FeaturesTests.class,//
|
|||
TimedTransactionalSpringRunnerTests.class,//
|
||||
HibernateSessionFlushingTests.class //
|
||||
})
|
||||
public class SpringJUnit4SuiteTests {
|
||||
public class SpringJUnit4TestSuite {
|
||||
/* this test case consists entirely of tests loaded as a suite. */
|
||||
}
|
||||
|
|
@ -76,16 +76,16 @@ public class TimedSpringRunnerTests {
|
|||
}
|
||||
|
||||
// Should Fail due to timeout.
|
||||
@Test(timeout = 200)
|
||||
@Test(timeout = 10)
|
||||
public void testJUnitTimeoutWithOneSecondWait() throws Exception {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(20);
|
||||
}
|
||||
|
||||
// Should Fail due to timeout.
|
||||
@Test
|
||||
@Timed(millis = 200)
|
||||
@Timed(millis = 10)
|
||||
public void testSpringTimeoutWithOneSecondWait() throws Exception {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(20);
|
||||
}
|
||||
|
||||
// Should Fail due to duplicate configuration.
|
||||
|
|
|
|||
Loading…
Reference in New Issue