lundi 8 août 2016

JUnit Test Cases for Config

I have a javaconfig file that looks like this:

@Configuration
public class ServiceConfig {
    @Autowired
    FooBean someBean;

    @Bean
    @Scope(value="session", proxyMode = ScopedProxyMode.TARGET_CLASS)
    public FooService fooService() {
        return new FooServiceImpl(someBean, fooB());
    }

    private Foo fooB() {
        return new FooB();
    }
}

And I have created a junit test file like so based on this stack answer :

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = ServiceConfig.class)
public class ServiceConfigTest {

}

But I have a couple questions:

  1. Should I test all my config files with this one junit test file? I have 4 config files in total including the ServiceConfig file, so in the ContextConfiguration should I just list them all out or have a junit test for each one indivually?

  2. What am I supposed to test here? I tried reading this spring guide but I'm not really understand what behavior I should test here....just if something gets autowired successfully?

Aucun commentaire:

Enregistrer un commentaire