当前位置:网站首页>JUnit unit test
JUnit unit test
2022-06-24 20:57:00 【Platonic】
Test categories :
1. Black box testing : No need to write code , Give input value , See if the output is the expected value .
2. White box testing : Need to write code , Pay attention to the specific implementation process of the program , such as :junit unit testing .
Junit Test use :
step :
1. Define a test class ( The test case )
Suggest : Test class name : Class name of the tested class Test CalulatorTest
Package name :xxx.xxx.xx.test cn.itcast.test
2. Define test methods : Can run independently
Suggest : Method name :test Test method name testAdd()
Return value :void
parameter list : Empty ginseng
3. Add to the method @test
4. Import junit rely on
public class CalculatorTest {
/* test add Method
* */
@Test
public void testadd(){
//1. Create a computer object
Calculator c=new Calculator();
//2. call add Method
int result = c.add(12, 12);
// System.out.println(result);
//3. Assertion , I assert that the result is 3
Assert.assertEquals(24,result);
}
}result :
24
边栏推荐
- Leetcode (146) - LRU cache
- What does virtualization mean? What technologies are included? What is the difference with private cloud?
- 微信小程序中使用vant组件
- Intermediary model -- collaboration among departments
- Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
- Dongyuhui is not enough to bring goods to "rescue" live broadcast
- Learn together and make progress together. Welcome to exchange
- 刚购买了一个MYSQL数据库,提示已有实例,控制台登录实例要提供数据库账号,我如何知道数据库账号。
- Use the transparent [x] cross button image in the dialog
- Smooth live broadcast | analysis of key technologies for live broadcast pain points
猜你喜欢

虚拟化是什么意思?包含哪些技术?与私有云有什么区别?

Prototype mode -- clone monster Army

Visitor model -- generation gap between young and middle-aged people

Byte and Tencent have also come to an end. How fragrant is this business of "making 30million yuan a month"?

苹果、微软、谷歌不再掐架,今年要合力干一件大事

物聯網?快來看 Arduino 上雲啦

顺序栈遍历二叉树

The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"

Mapstacks: data normalization and layered color layer loading

Several common command operations in win system
随机推荐
Vxlan and MPLS: from data center to Metro Ethernet
VXLAN 与 MPLS:从数据中心到城域以太网
You can capture fingerprints with a mobile camera?! Accuracy comparable to signature and monogram, expert: you are aggravating discrimination
虚拟化是什么意思?包含哪些技术?与私有云有什么区别?
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
大一女生废话编程爆火!懂不懂编程的看完都拴Q了
Why do we always "give up halfway"?
“拯救”直播带货,一个董宇辉还不够
What does virtualization mean? What technologies are included? What is the difference with private cloud?
Postman assertion
托管服务与SASE,纵享网络与安全融合 | 一期一会回顾
Hosting service and SASE, enjoy the integration of network and security | phase I review
Leetcode (146) - LRU cache
图的基本概念以及相关定义
maptalks:数据归一化处理与分层设色图层加载
Wechat applet custom tabbar
Batch capitalization of MySQL table names
Leetcode(455)——分发饼干
2022年最新四川建筑八大员(电气施工员)模拟题库及答案
Popupwindow touch event transparent transmission scheme