如何在Spring MVC工程中进行单元测试
来源:互联网 发布:宜宾广电网络客服热线 编辑:程序博客网 时间:2024/06/06 10:58
直接以代码方式演示如何在Spring MVC工程中进行单元测试:
package net.chinaedu.projects.dubhe;import java.util.List;import net.chinaedu.projects.dubhe.publisher.IPublisherService;import net.chinaedu.projects.venus.domain.Publisher;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.ActiveProfiles;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;@ActiveProfiles({"test"})@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"classpath:conf/spring/app-context.xml", "classpath:conf/spring/servlet-context.xml"})//指定工程中Spring配置xml文件public class JUnit4Test extends AbstractJUnit4SpringContextTests {//AbstractTransactionalJUnit4SpringContextTests@Autowired private IPublisherService publisherService; @Test public void testFindAllPublisher(){ List<Publisher> publisherList = publisherService.findAll(); for (Publisher publisher:publisherList) {System.out.println(publisher.getId() + " , " + publisher.getName());} }}
0 0
- 如何在Spring MVC工程中进行单元测试
- android如何在项目中进行单元测试
- 如何在VS中进行单元测试
- 在Spring-MVC.xml中进行配置
- Controller 使用RestTemplate进行单元测试 spring mvc
- 在Spring中结合Dbunit对Dao进行集成单元测试
- 使用内存数据库H2在spring中进行单元测试
- 在Spring应用中使用junit进行单元测试
- NUnit.Framework在VS2015中如何进行单元测试
- 如何在eclipse中通过Juit进行单元测试
- 如何在Spring MVC中自定义注解
- 如何在Spring MVC中自定义注解
- VS2010中如何进行单元测试
- SSH中如何进行单元测试
- SSH中如何进行单元测试
- 在android中进行单元测试
- 在AndroidStudio中进行单元测试
- Spring MVC中Controller如何进行重定向
- HashSet和HashMap的区别
- MySQL存储过程2.0
- TestNG常见问题
- MyBatis、Spring、maven整合
- Composer 001
- 如何在Spring MVC工程中进行单元测试
- url encodeURI转中文
- 苹果电脑连上WIFI了 但出现个感叹号
- oracle 表空间
- airbnb/javascript
- Android事件总线 ( AndroidEventBus ) 框架发布
- 理解jquery的$.extend()、$.fn和$.fn.extend()
- Jquery实现点击某一checkbox时,value类似的checkbox也选中
- Log Parser 2.2 + Log Parser Lizard GUI 分析IIS日志示例