当前位置:网站首页>Common assertions in JUnit testing
Common assertions in JUnit testing
2022-06-12 14:42:00 【Micro blog】
1、 Assert whether the captured exception information contains some string content
try {
//TODO
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String msg = sw.toString();
String exp = " Customer information does not exist , Do not modify ";
Assert.assertNotEquals(-1, msg.indexOf(exp));
}
2、 Asserts whether the caught exception is a specified exception
try {
//TODO
} catch (Exception e) {
Assert.assertEquals(e.getClass(), RPCTimeoutException.class);
}
3、 Asserts whether the elapsed time is the specified time , among System.currentTimeMillis() Is to obtain the current system time ,start It's the start time
String taketime = Long.toString(System.currentTimeMillis() - start);
Assert.assertNotSame(-1, taketime.indexOf("10"));
Time to be consumed here (Long type ) convert to string After the type , Compare it with the estimated time
边栏推荐
- 程序构造和解释之第一章习题
- Player practice 18 xresample
- Huawei equipment configuration BGP as number replacement
- Unhandled exception stack overflow
- C secret arts script Chapter 2 (detailed explanation of pointer) (Section 1)
- webdriver入门
- Appnium (II) installation and basic use of mitmproxy
- PMP agile knowledge points
- Player practice 15 xdemux and avcodecparameters
- [system. Currenttimemillis()] current timestamp: the number of milliseconds that have elapsed since the current system time was 0:00:00 on January 1, 1970
猜你喜欢

selenium进阶

How to package QT program learning records with inno setup

Analysis of two-dimensional array passing as function parameter (C language)
![[wechat applet] 4 Introduction to wechat developer tools](/img/9d/0d6c5cc675fb70dde98b25649bd8d8.jpg)
[wechat applet] 4 Introduction to wechat developer tools
![[OCR] aspriseocr C # English, number recognition (not Chinese)](/img/80/198145df663d2eeec6b8b1d7bc47b6.png)
[OCR] aspriseocr C # English, number recognition (not Chinese)

QT realize picture dragging

新技术:高效的自监督视觉预训练,局部遮挡再也不用担心!

华为设备配置BGP AS号替换

Junit多线程的写法

Appnium (I) basic use of appnium
随机推荐
[wechat applet] 6.1 applet configuration file
C secret script Chapter 1: data storage (in-depth analysis) supplement
Player practice 15 xdemux and avcodecparameters
ADSL
QT database realizes page turning function
Reverse the encryption parameters of a hot water software
Configuring OSPF pseudo connection for Huawei devices
Producers (send syncask requests) and consumers (with xxxask monitoring and Implementation)
【Instant】1. Equivalent to date class 2 Represents a moment
Ppt cannot be opened, always prompt how to fix it
Autofac初学(1)
Huawei equipment is configured with H virtual private network
启明云端分享| 通过Matter协议实例演示开关通过matter协议来做到对灯亮灭的控制
Unit test (I) unit test with JUnit
Markdown edit
【OCR】AspriseOCR C# 英文、数字识别(中文不行)
Thinking: what is asynchrony and thread safety
Player actual combat 13 create qtopengl project to promote window control and reload qoopenglwedge
用游戏来讲序列化与反序列化机制
C secret arts script Chapter 2 (detailed explanation of pointer) (Section 2)