当前位置:网站首页>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
边栏推荐
- Smooth live broadcast | analysis of key technologies for live broadcast pain points
- Summary of idea practical skills: how to rename a project or module to completely solve all the problems you encounter that do not work. It is suggested that the five-star collection be your daughter
- 对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿
- 顺序栈1.0版本
- Why do we always "give up halfway"?
- [performance tuning basics] performance tuning strategy
- The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
- 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
- Enjoy yuan mode -- a large number of flying dragons
- 《梦华录》“超点”,鹅被骂冤吗?
猜你喜欢
随机推荐
Selenium crawl notes
The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
What will you do if you have been ignored by your leaders at work?
刚购买了一个MYSQL数据库,提示已有实例,控制台登录实例要提供数据库账号,我如何知道数据库账号。
建立自己的网站(14)
Intermediary model -- collaboration among departments
伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
Variable setting in postman
C langage pour le déminage (version simplifiée)
Batch capitalization of MySQL table names
Leetcode (455) - distribute cookies
Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO
Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
Builder mode -- Master asked me to refine pills
基于QT+MySQL的相机租赁管理系统
情绪识别AI竟「心怀鬼胎」,微软决定封杀它!
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
The largest DPU manufacturer in history (Part 1)
After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
Design of routing service for multi Activity Architecture Design









