Junit4测试Spring
2
3 import javax.annotation.Resource;
4
5 import org.junit.Test;
6 import org.junit.runner.RunWith;
7 import org.springframework.test.context.ContextConfiguration;
8 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9
10 @RunWith(SpringJUnit4ClassRunner.class)
11 @ContextConfiguration(locations={"../../../../applicationContext.xml","../../../../applicationDatasource.xml"})
12 public class UserServiceTest {
13 @Resource
14 private IUserService userService;
15
16 @Test
17 public void testAddOpinion1() {
18 userService.downloadCount(1);
19 System.out.println(1);
20 }
21 @Test
22 public void testAddOpinion2() {
23 userService.downloadCount(2);
24 System.out.println(2);
25 }
26 }
27
注意需要新的Jar包如下
javassist-3.4.GA.jar
hibernate3.jar
hibernate-annotations.jar
尤其注意用新版的,旧版会出现类未找到的异常
Junit4测试Spring的更多相关文章
- web项目中 集合Spring&使用junit4测试Spring
web项目中 集合Spring 问题: 如果将 ApplicationContext applicationContext = new ClassPathXmlApplicationContext(& ...
- 使用JUnit4测试Spring
测试DAO import static org.junit.Assert.*; import org.junit.Before; import org.junit.Ignore; import org ...
- junit4测试 Spring MVC注解方式
本人使用的为junit4进行测试 spring-servlet.xml中使用的为注解扫描的方式 <?xml version="1.0" encoding="UTF- ...
- 就是这么简单(续)!使用 RestAssuredMockMvc 测试 Spring MVC Controllers
就是这么简单(续)!使用 RestAssuredMockMvc 测试 Spring MVC Controllers 转载注明出处:http://www.cnblogs.com/wade-xu/p/43 ...
- JUnit4 测试示例
1. JUnit4 测试示例 // Calculator.java public class Calculator{ public int add(int a, int b){ return a + ...
- (转)编写Spring的第一个案例并测试Spring的开发环境
http://blog.csdn.net/yerenyuan_pku/article/details/52832145 Spring4.2.5的开发环境搭建好了之后,我们来编写Spring的第一个案例 ...
- Junit4 测试代码
Junit4 测试代码 import org.junit.Test; import org.junit.runner.RunWith; @RunWith(SpringJUnit4ClassRunner ...
- 利用Spring的junit4测试
利用Spring的JUnit4进行测试 不需要再显式创建Spring容器和getBean @RunWith(SpringJUnit4ClassRunner.class) @ContextConfigu ...
- spring中试用junit4测试
一:加入jar包 <!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId& ...
随机推荐
- How to trace the Geolocation of network traffic
A case about suspicious malware App. A forensic examiner capatured some pcap files and he'd to know ...
- java复习(8)---I/O
本节复习java常用i/o,输入输出流. 先放上样例代码.方便参考,可以轻松看懂. package re08; import java.io.*; import java.util.Scanner; ...
- 一、AspNet Core通过控制台编译程序的基本指令:
1.先创建文件夹 mkdir "文件夹"2.在对应的文件夹里边 用 dotnet new 命令创建了Program.cs和project.json俩个文件3.使用 dotnet r ...
- poj2653线段相交判断
Stan has n sticks of various length. He throws them one at a time on the floor in a random way. Afte ...
- 微信小程序(组件demo)以及预览方法:(小程序交流群:604788754)
1. 获取微信小程序的 AppID 登录 https://mp.weixin.qq.com ,就可以在网站的"设置"-"开发者设置"中,查看到微信小程序的 Ap ...
- 微信小程序之获取当前位置经纬度以及地图显示
最近刚开始接触微信小程序,在弄懂其结构以及相关接口之后,准备着手实现一个小程序,功能包括--获取用户当前位置的经纬度,在地图上查看位置,通过地图获取不同位置的经纬度. 微信小程序的主体部分包括: 新增 ...
- (转)html中 cookie设置
box=="checkBox '是否记住用户密码'": window.onload=function init() { var box = getCookie(" ...
- 由于losf引起的pxc启动报错处理
PXC主节点启动完成后,再启动node1,error日志报错: 2017-05-02T15:23:42.830888Z 0 [ERROR] WSREP: Failed to read 'ready & ...
- linux中/etc/profile、/etc/profile.d/、/etc/bashrc、~/.bashrc、~/.bash_profile、~/.bash_logout的作用与区别
作用: /etc/profile:登录时用来设置环境变量,执行文件中的命令,对所有用户生效. /etc/profile.d/:登录时和执行bash命令打开子shell时执行目录下所有已.sh结尾的脚本 ...
- Linux下的Jenkins+Tomcat+Maven+Gitlab+Shell环境的搭建使用(jenkins自动化部署)
jenkins自动化部署 目标:jenkins上点构建(也可以自动检查代码变化自动构建)>>>项目部署完成. 一.安装jenkins 1.下载jenkins 这里我选择的是war包安 ...