Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.82 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JUnit: Can I keep the common parts of the spring context?
  2. @RunWith(SpringJUnit4ClassRunner.class)
  3. @ContextConfiguration(locations = { "classpath:beans.xml" }, inheritLocations = true)
  4. public abstract class TestBase {
  5. }
  6.  
  7. @RunWith(SpringJUnit4ClassRunner.class)
  8. @ContextConfiguration(locations = { "classpath:extraBeansOne.xml" }, inheritLocations = true)
  9. public class TestOne extends TestBase {
  10.  
  11.   @Test
  12.   public void testA() {
  13.   }
  14. }
  15.  
  16. @RunWith(SpringJUnit4ClassRunner.class)
  17. @ContextConfiguration(locations = { "classpath:extraBeansTwo.xml" }, inheritLocations = true)
  18. public class TestTwo extends TestBase {
  19.  
  20.   @Test
  21.   public void testB() {
  22.   }
  23. }
  24.        
  25. @RunWith(Suite.class)
  26. @Suite.SuiteClasses({ TestOne.class, TestTwo.class })
  27. public class TestSuite {
  28. }
  29.        
  30. <beans ...>
  31.   <bean id="testBean" class="com.example.TestBean" />
  32. <bean>