当前位置:网站首页>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
边栏推荐
- More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
- Sequence stack version 1.0
- 首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
- [performance tuning basics] performance tuning standards
- Responsibility chain mode -- through interview
- Set up your own website (14)
- Selenium crawl notes
- 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"
- Where is 5g really powerful? What is the difference with 4G?
- It is said that Tencent officially announced the establishment of "XR" department to bet on yuanuniverse; Former CEO of Google: the United States is about to lose the chip competition. We should let T
猜你喜欢

Vant component used in wechat applet

Stackoverflow annual report 2022: what are developers' favorite databases?

16 excellent business process management tools

I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world

二叉树的基本性质与遍历

实现基于Socket自定义的redis简单客户端

Camera rental management system based on qt+mysql

Memo mode - game archiving

Image panr
![[普通物理] 光栅衍射](/img/f3/965ff7cd3bb76b4f71b69b9d12ece3.png)
[普通物理] 光栅衍射
随机推荐
Intermediary model -- collaboration among departments
【建议收藏】时间序列预测应用、paper汇总
DX12引擎开发课程进度-这个课程到底讲到哪里了
How to enhance influence
What are the problems with traditional IO? Why is zero copy introduced?
Bytebase joins Alibaba cloud polardb open source database community
Mapstacks: data normalization and layered color layer loading
Memo mode - game archiving
JMeter response assertion
微信小程序中使用vant组件
[multi thread performance tuning] multi thread lock optimization (Part 1): optimization method of synchronized synchronization lock
Why do we always "give up halfway"?
[普通物理] 光栅衍射
Agency mode -- Jiangnan leather shoes factory
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
Leetcode(146)——LRU 缓存
伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
浅谈MySql update会锁定哪些范围的数据
I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
Procedural life: a few things you should know when entering the workplace