当前位置:网站首页>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
边栏推荐
猜你喜欢

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

Mapstacks: data normalization and layered color layer loading

大一女生废话编程爆火!懂不懂编程的看完都拴Q了

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

Leetcode (135) - distribute candy

对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿

The four stages of cloud computing development have finally been clarified

maptalks:数据归一化处理与分层设色图层加载

传统的IO存在什么问题?为什么引入零拷贝的?

年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
随机推荐
Haitai Advanced Technology | application of privacy computing technology in medical data protection
Bytebase加入阿里云PolarDB开源数据库社区
Apple doesn't need money, but it has no confidence in its content
Visitor model -- generation gap between young and middle-aged people
Variable setting in postman
Basic operation of sequence table
全上链哈希游戏dapp系统定制(方案设计)
With its own cells as raw materials, the first 3D printing ear transplantation was successful! More complex organs can be printed in the future
云计算发展的 4 个阶段,终于有人讲明白了
2021-09-30
When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
"Super point" in "Meng Hua Lu", is the goose wronged?
网络安全审查办公室对知网启动网络安全审查
主数据建设的背景
Leetcode(455)——分发饼干
Leetcode (455) - distribute cookies
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
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
How to enhance influence
Procedural life: a few things you should know when entering the workplace