test测试类

2023-05-16

package com.chen.test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.chen.dao.appDao.demoDao;
import com.chen.model.appModel.demoModel;
import com.chen.service.userSystem.appI.demoService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath*:/spring/applicationContext.xml"})
public class Ttest {
	
	@Autowired
	private demoDao   dao;
	
	@Autowired
	private demoService   service;
	/**
	 *  调用dao层方法
	 */	
	@Test
	public void test01() {
		demoModel model = new demoModel();
		model.setOpenId("ogwH2UjwguI13QRC73TYA");
		model.setXz("武昌区");
		model.setYmurl("www.baidu.com");
		model.setScsj("2018-11-23 08:18:12");
		dao.adddemo(model);
		System.out.println("运行");
	}
/**
 * 调用业务层方法
 */
	@Test
	public void test02() {
		demoModel model = new demoModel();
		model.setOpenId("ogH2Ujg3QRC73TYA");
		model.setXz("武昌区");
		model.setYmurl("www.baidu.com");
		
		Map<String, Object> adddemo = service.adddemo(model);
		System.out.println("运行"+adddemo);
	}

}

步骤:
1.项目–>右键–>build Path–>Configure Build Path...–>Libraries–>Add Library–>JUnit–>Next
版本version 选JUinut4(和JUinut5比较相对稳定)
Finish
2.测试类上添加导入下面两列代码

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath*:/spring/applicationContext.xml"})

3.测试类上加注解@Test
4.方法调用与控制层,业务实现层类调用方法一致,引用接口,调用方法。
5.测试类完整使用案例可查看顶部引用的代码。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

test测试类 的相关文章

  • 【Lecture 4.3】Test Cases and Exception

    18 1 Introduction Test Cases Test Cases以一种可以自动检查的方式表达了对程序的需求 具体地说 xff0c 测试test断言asserts 程序在其执行的某个特定点上的状态 我们之前曾建议 xff0c 在
  • openssl:Can‘t load /home/test/.rnd into RNG

    Can 39 t load home test rnd into RNG 140409534742976 error 2406F079 random number generator RAND load file Cannot open f
  • 初学shell脚本之-bash: /home/test/hello.sh: Permission denied

    今天学习shell脚本在windows写了个shell脚本 span class token operator span span class token operator span bin span class token operato
  • test

    1 overrides the s4 notdlg class items as display none lt script type 61 34 text javascript 34 gt var fV4UI 61 true lt sc
  • Java线程test

    1 银行有一个账户有两个储户存分别向同一个账户存3000 元 xff0c 每次存1000 xff0c 存3次 每次存完打印账户余额 问题 xff1a 该程序是否有安全问题 xff0c 如果有 xff0c 如何解决 xff1f 提示 1 xf
  • Permutation Test

    常规步骤 xff1a 一般 多组间样本均数的比较是先做正态性检验和方差齐性 xff0c 然后在各组 都满足 正态性和方差齐性的前提下做方差分析 如果数据呈现正态分布 xff0c 但方差不齐 xff0c 则可以选择近似方法 Welch法 和
  • Permutation test(排列(组合)检验)

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 对Permutation test 的首次描述可追溯到上个世纪30年代 Fisher 1935 和Pitman 1937 介绍了其在线性统计模型中的应用 但该法计算工作量过
  • 1:Unit test and main function-Java API 实战

    目录 1 抛出企业问题 xff0c 脱离main测试 xff0c 模块化编程2 Junit单元测试的含义和用途3 怎么获取各种Jar包 xff1f Maven Repository 获取各类各个版本的jar xff0c 这就是仓库 脱离老师
  • Using lxd to do vlan test (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 08 15 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 问题 客户说sriov虚机里收不着arp reply 他们的s
  • INSTALL_FAILED_TEST_ONLY

    查看博客 http www enjoytoday cn posts 159 Android studio安装apk无法安装 xff0c 报错误 xff0c 网上搜索可以看到都说是 调用者不被允许测试的测试程序 xff0c 但具体这句话具体是
  • Test Case Framework (TCF) 简介

    TCF is a system that simplifies the creation and execution of test cases automation for that matter with minimal setup e
  • Test Case Framework (TCF) tcf 参数

    root 64 embargo ww13 tcf help usage tcf h v log pid tid log time config file CONFIG FILE py p CONFIG PATH state path STA
  • train,val,test的区别

    参考 xff1a https www mobibrw com 2017 7966
  • NS3 的 ipv4-static-routing-test-suite 源码分析

    下面进行源码注释 xff1a End to end tests for Ipv4 static routing include 34 ns3 boolean h 34 include 34 ns3 config h 34 include 3
  • test

    lt DOCTYPE html gt lt html lang 61 34 en 34 gt lt head gt lt meta charset 61 34 utf 8 34 gt lt meta http equiv 61 34 X U
  • 在 Bash 中检查文件是否为空的 5 种方法

    在 Linux 中 空文件是大小为零字节的文件 这意味着该文件不包含任何数据 并且在文本编辑器中打开时没有任何内容 可以使用 touch 命令创建一个空文件 touch myfile txt 这将在当前目录中创建一个名为 myfile tx
  • IDEA的Junit安装(添加jar包)

    1 安装junit插件 1 打开IDEA 点击文件 选择设置 setting 2 选择Plugins gt 点击Browse repositories 3 在搜索框中搜索Junit gt 找到Junit Generator V2 0点击 g
  • 如何评估加解密代码?

    在不深入研究代码的具体实现的情况下 如何评估加解密代码的有效性 强度 背景 迫于无赖 项目组只能安排1位新手设计一系列的加密算法 用于对本地文件和二进制代码的加密 幸运的是 对加密强度并没有过高的要求 但也希望能够有效的评估代码 并实现自动
  • shell test功能

    test测试功能 对于要测试系统上面某些文件或其相关属性时 可以使用test进行测试 test会根据相关功能返回True或False 测试文件类型test e filename 测试功能 意义 e 该文件是否存在 f 该文件名是否存在且为文
  • 嵌入式经典面试题

    文章目录 一 常见面试题 1 用预处理指令 define 声明一个常数 用以表明1年中有多少秒 忽略闰年问题 2 写一个 标准 宏MIN 这个宏输入两个参数并返回较小的一个 3 预处理器标识 error的目的是什么 4 数据声明 5 sta

随机推荐