spring + junit 测试
spring + junit 测试
需要一个工具类
package com.meizu.fastdfsweb;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring-context.xml")
public abstract class BaseSpringContextUnitTest {
}
测试例子:
package com.meizu.fastdfsweb.entity;
import junitx.framework.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.meizu.fastdfsweb.BaseSpringContextUnitTest;
public class ClusterConfigTest extends BaseSpringContextUnitTest {
@Autowired
ClusterConfig clusterConfig;
@Test
public void testGetClusterNum() {
System.out.println(clusterConfig);
Assert.assertEquals(2, clusterConfig.getClusterNum());
}
}
spring + junit 测试的更多相关文章
- Spring Junit测试(非web,即不包含Controller测试)
使用Spring-Test对Spring框架进行单元测试 配置过程: lib加入导入spring-test.jar和junit包 或者使用Maven依赖: <dependency> < ...
- maven+spring+junit测试要注意的事情
使用maven方式创建webapp工程的资料网上一大堆,在这里也不详细说了.在创建完成之后,里面说到要转动态web工程时要切换为3.0版本,但是我本地切换不了,网上的方法好像也没用,暂时也没用到这块. ...
- Struts2+Spring+Mybatis+Junit 测试
Struts2+Spring+Mybatis+Junit 测试 博客分类: HtmlUnit Junit Spring 测试 Mybatis package com.action.kioskmoni ...
- spring boot web开发 简单的增删改查和spring boot 自带的Junit测试 案例
创建 web项目 配置pom.xml文件 ------相当于jar包 配置application.yml -----配置文件(spring数据库连接.server服务.logging日志等) 创建 ...
- 原创:Spring整合junit测试框架(简易教程 基于myeclipse,不需要麻烦的导包)
我用的是myeclipse 10,之前一直想要用junit来测试含有spring注解或动态注入的类方法,可是由于在网上找的相关的jar文件进行测试,老是报这样那样的错误,今天无意中发现myeclips ...
- Spring Boot 解决方案 - JUnit 测试
简单的 JUnit 项目 回顾一下创建并运行简单的 JUnit 测试项目,先添加 JUnit 依赖然后编写类似如下模板的测试类,使用 IDE 的话直接用插件运行就行, 使用 Maven 的话运行命令 ...
- Spring整合junit测试
本节内容: Spring整合junit测试的意义 Spring整合junit测试 一.Spring与整合junit测试的意义 在没整合junit之前,我们在写测试方法时,需要在每个方法中手动创建容器, ...
- Spring框架下Junit测试
Spring框架下Junit测试 一.设置 1.1 目录 设置源码目录和测试目录,这样在设置产生测试方法时,会统一放到一个目录,如果没有设置测试目录,则不会产生测试代码. 1.2 增加配置文件 Res ...
- Spring+Junit+Mock测试web项目,即Controller
准备:Maven依赖 <!-- Spring和MVC的包这里不列出来了,webmvc,aspects,orm,其他maven会自动导 --> <dependency> < ...
随机推荐
- Squares of a Sorted Array
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each ...
- Spring4学习回顾之路02—IOC&DI
IOC&DI介绍 ●IOC:(Inversion of Control) :控制反转(反向获取资源) 其思想是反转资源获取的方向.传统的资源上查找方式要求组件向容器发起请求查找资源,作为回应, ...
- PAT B1024/A1073 科学计数法
书中AC代码 #include <cstdio> #include <cstring> #include <iostream> #include <cmath ...
- Magazine Delivery(POJ1695)【DP】
题意:要求用三辆车往n座城市投递货物,起点都在一号城市,每辆车可以载任意数量的货物,投递顺序必须与城市编号递增序一致,并且,每次同时都只能有一辆车在跑路.求最短总路径之和. 思路:每时每刻,能够充分决 ...
- Open API
OAuth和SSO都可以做统一认证登录,但是OAuth的流程比SSO复杂.SSO只能做用户的认证登录,OAuth不仅能做用户的认证登录,开可以做open api开放更多的用户资源. Open API即 ...
- 使用JWT的ASP.NET CORE令牌身份验证和授权(无Cookie)——第1部分
原文:使用JWT的ASP.NET CORE令牌身份验证和授权(无Cookie)--第1部分 原文链接:https://www.codeproject.com/Articles/5160941/ASP- ...
- Stacey矩阵简介
1. Stacey 矩阵包含哪几个区域? 1区:Simple 第一个区域,需求明确,技术(解决方案)也确定,这类项目就是简单的项目(Simple):比如注册一个新公司,需求很明确,手续也很清楚,就那么 ...
- luogu题解 P2860[USACO冗余路径Redundant Paths] 缩点+桥
题目链接 https://www.luogu.org/problemnew/show/P2860 https://www.lydsy.com/JudgeOnline/problem.php?id=17 ...
- js中with的作用
js中with的作用当一个对象有多个需要操作的属性或方法时,可以使用如<体>试验<script type=“text/javascript”>var o=文件.创建元素(“DI ...
- 把json1赋值给json2,修改json2的属性,json1的属性也一起变化
let json1 = { a: 1}let json2 = json1json2.a = 5 console.log(json1.a) // 5 console.log(json2.a) // 5 ...