I have a jUnit test case to test spring managed beans of helpers, utility, services etc. So that I have set the unit test class with SpringJUnit4ClassRunner and contextConfiguration. e.g. -
@ContextConfiguration({ "classpath:context-file.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public class UnitTests {
@Test
public void test1() {
//...
}
@Test
public void test2() {
//...
}
@Test
public void test3() {
//...
}
@Test
public void test4() {
//...
}
}
I want to run these four(or more) unit test on some condition at run time e.g. if internet is available then run test UnitTests.test1(), if database is connected then run UnitTests.test2(), if image files directory is present then run test UnitTests.test3(), if a remote server is responding properly then run test UnitTests.test4().
Although I have went through jUnit org.junit.Assume but it doesn't suit, it can either enable the test framework to run all tests or skip all tests. @Ignore is also not applicable for these scenario. Also went through junit-ext (https://code.google.com/p/junit-ext/), but its dependency is not available on maven-central repository (junit-ext-maven-dependency). Please anybody help me out with some peace of code here.