Organizational Research By

Surprising Reserch Topic

java annotations code simplifications


java annotations code simplifications  using -'java,spring,testing,annotations,spring-test'

I am looking for a way to simplify the following code.

@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
        // My configuration classes
})
public class MyServiceTest {
    @Autowired
    private MyService service;

    @Test
    public void myTest() {
        Assert.assertTrue(service != null);
    }
}


I have many configuration classes and I don't want to put them into each test class. So I got the idea to create my own annotation:

@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
        // My configuration classes
})
public @interface IntegrationTests {
}


I try to use it in the following way:

@IntegrationTests
public class MyServiceTest {
    @Autowired
    private MyService service;

    @Test
    public void myTest() {
        Assert.assertTrue(service != null);
    }
}


But it doesn't work. Any idea?
    
asked Oct 6, 2015 by gauravg.gwl
0 votes
12 views



Related Hot Questions



Government Jobs Opening


...