JUNIT4 断言assertThat greaterThan
使用assertThat,项目要引用以下jar包
junit-4.12.jar
hamcrest-core-1.3.jar
hamcrest-libriry-1.3.jar
pom.xml
<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope>
</dependency>
<dependency><groupId>org.hamcrest</groupId><artifactId>hamcrest-core</artifactId><version>1.3</version><scope>test</scope>
</dependency>
<dependency><groupId>org.hamcrest</groupId><artifactId>hamcrest-library</artifactId><version>1.3</version><scope>test</scope>
</dependency>
Test1.java
package test.cms;//import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
//import static org.junit.Assert.*;import org.junit.Test;public class Test1 {@Testpublic void test() {//fail("Not yet implemented");assertThat(1, greaterThan(0));}}
如果报错找不方法
The method assertThat(int, int) is undefined for the type Test1
The method greaterThan(int) is undefined for the type Test1
引入类即可
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
参考:
Junit4中的新断言assertThat的使用方法
JUNIT4 断言assertThat greaterThan相关推荐
- Junit4中的新断言assertThat的使用方法
引入junit4的jar包 import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.CoreMatchers.*; ...
- 断言assertthat用法
一般匹配符 1.assertThat( testedNumber, allOf( greaterThan(8), lessThan(16) ) ); 注释: allOf匹配符表明如果接下来的所有条件必 ...
- java断言--assertThat用法
做为一个准备向自动化测试进军的小测试,断言不会是不行.我当前主擅长的就是java和python,这里是java的断言总结. @Test public void testHamcrestMatchers ...
- 白盒测试(单元测试JUnit使用断言assertThat中startsWith、endsWith方法)
目录 一.背景知识 二.assertThat-字符串相关匹配符 1.startsWith 2.endsWith 三.代码演示
- springboot项目使用junit4进行单元测试,maven项目使用junit4进行单元测试
首先,maven项目中引入依赖 <dependency><groupId>junit</groupId><artifactId>junit</ar ...
- 安利一下断言利器AssertJ
AssertJ是我目前见过的最强大的断言api,没有之一. 官网传送门 为什么使用assertJ? 1.流式断言,代码即用例,直观易懂. 举个例子: 传统的junit或者testng,判断一个字符串包 ...
- 流式断言器AssertJ介绍
本文来自网易云社区 作者:范旭斐 大家在使用testng.junit做自动化测试的过程中,经常会用到testng.junit自带的断言器,有时候对一个字符串.日期.列表进行断言很麻烦,需要借助到jdk ...
- SpringBoot系列: 单元测试
SpringBoot 项目单元测试也很方便, Web项目中单元测试应该覆盖: 1. Service 层 2. Controller 层 本文前半部分讲解是一些测试基础配置. 对于Service和Con ...
- Spring Boot干货系列:(十二)Spring Boot使用单元测试 | 嘟嘟独立博客
原文地址 2017-12-28 开启阅读模式 Spring Boot干货系列:(十二)Spring Boot使用单元测试 Spring Boot干货系列 Spring Boot 前言 这次来介绍下Sp ...
最新文章
- Mac无损音乐播放器Audirvana plus
- reactor设计模式 1
- 7种常见的数据分析基本思路,满足你职场95%的需求
- SpringBoot整合阿里Druid数据源及Spring-Data-Jpa
- app-v 4.6 management server部署(一)
- RegExp(正则表达式)
- 华为拿下支付牌照 微信、支付宝又迎来一个新对手
- 拓扑排序和关键路径算法----关键路径算法 (C语言实现)
- 安装Windows XP出现0X0000007B的解决方法
- Wei框架源码解读(1)
- Windows Server 2016 IPAM 服务管理-李海园-专题视频课程
- 这一次,抄袭的人竟然是Facebook!美版微信要出现了吗?!
- poi修改excel单元格值导致单元格变成橙色的问题(WPS)
- jsp实验中:tag文件报java.util.ArrayList cannot be cast to java.lang.String
- 读 孙卫琴《Tomcat与Javaweb开发技术详解》
- 【树莓派初始化】教你从0开始搭建树莓派的使用环境
- 领导合影站位图_领导座次安排图,没有人会教你这些,但非常重要!(建议收藏)...
- 集合各大牛博客的web前端面试题
- 学习英音的电影和电视剧
- openblas android平台,ubuntu16.04 openblas库安卓arm64-v8a编译