import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.job36.admanage.service.AdAdTypeService;
import com.job36.admanage.vo.AdAdTypeVO;
public class AdTypeTest {
ApplicationContext dsContext = null;
AdAdTypeService adAdTypeService = null;
AdAdTypeVO adAdTypeVO = null;
@Before
public void init() throws Exception {
dsContext = new ClassPathXmlApplicationContext(new String[] {
"applicationContext.xml", "applicationContext-dao.xml",
"applicationContext-service.xml" });
adAdTypeVO = new AdAdTypeVO();
adAdTypeVO.setTypeId(1);
adAdTypeVO.setTypeName("banner");
adAdTypeVO.setMessage("测试");
adAdTypeService = (AdAdTypeService) dsContext.getBean("AdAdTypeService");
}
@Test
public void findByCondition() {
assertEquals(adAdTypeService.findByCondition(adAdTypeVO).getListAdAdTypeVO().get(0), adAdTypeVO);
}
}
junit4 单元测试service(Spring)方法
最新推荐文章于 2024-05-15 21:26:04 发布
本文介绍了一个名为AdTypeTest的Java单元测试类,该类使用了JUnit进行测试,并依赖于Spring框架进行bean的初始化。主要测试了AdAdTypeService的findByCondition方法,通过预设的数据验证方法的正确性。
10万+

被折叠的 条评论
为什么被折叠?



