Friday, September 8, 2017

@ContextConfiguration with class

If your spring application is a booty, you would simply go with an @SpringBootTest to achieve the similar result. But unfortunately, some of our obsolete projects are far behind this.

In one of my post, I would have briefed how to configure random beans. I need to test the same. i.e. I need the context information of this random bean to have specific test cases on top of them.


This is the configuration class and
This is the test case for the same.

AnnotationConfigContextLoader is the one that facilitates this

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=PnlRandomizerConfiguration.class, loader = AnnotationConfigContextLoader.class)
public class PnlRandomizerTest {


I would encourage you read more about this here

Note that it cannot load both xml and class.
More about it here and here

No comments:

Post a Comment