vendredi 17 juillet 2015

How to inject the value coming from a rule into a test spring context?

suppose you have the following situation while testing a spring context

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigClass.class})
public class IntegrationTest   {

 @ClassRule 
 static PluginThatSetsUpSomethingEmbedded pluginRule = new PluginThatSetsUpSomethingEmbedded();



}

now one of my Spring beans needs something that can only come out of the rule, like:

pluginRule.getEmbeddedToolConfig()

how can I provide my bean with that config, notice that the rule is ClassRule and is static too...

Aucun commentaire:

Enregistrer un commentaire