My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
TestWithSpring  
Updated Feb 4, 2010 by zee.ho...@gmail.com

junit-ext also provides the JunitExtSpringRunner to let you filter the testcases when running the test with Spring. The only different is to use JunitExtSpringRunner instead of JunitExtRunner

@RunWith(JunitExtSpringRunner.class)
@ContextConfiguration(locations = {
        "classpath:**/applicationContext-repository.xml"
        })
public class ShouldWorkWithSpringTest {
    @Autowired
    private SampleRepository repository;

    @Test
    @RunIf(NeverSatisfiedChecker.class)
    public void shouldBeIgnored() {
        throw new RuntimeException();
    }

    @Test
    @RunIf(AlwaysSatisfiedChecker.class)
    public void shouldRunWithInstantiatedRepository() throws Exception {
        assertThat(repository, is(not(nullValue())));
    }

}

All contents


Sign in to add a comment
Powered by Google Project Hosting