Simple Junit Example:
//load spring bean configure file
@ContextConfiguration(inheritLocations=true, locations={ "classpath:bhg-services.xml" })
public class ValueMealsTest extends AbstractBaseSpringTest{
@Resource
private IRecipeDao recipeDao;
@Ignore
@Test
@Transactional
public void testGetStores(){
// here code to invoke the service
assertNotNull(storePromotionCounts);
assertTrue(storePromotionCounts.size()==1);
assertTrue(storePromotionCounts.get(0).getPromotionCount()==2);
}
}// class
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:foodlabContext.xml","classpath:service.xml","classpath:business.xml"})
class AbstractBaseSpringTest{
@Before
public void setupRequestResponse() {
// code to run before the test case start execute
}
public void testMethodName(){
//code to test the service
}
@After
public void setupRequestResponse() {
// code to run after the all test case execution completed
}
}// class
No comments:
Post a Comment