当前位置:网站首页>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
边栏推荐
- Map跟object 的区别
- 红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
- 用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
- Prototype mode -- clone monster Army
- [suggested collection] time series prediction application and paper summary
- 史上最全DPU厂商大盘点(上)
- Mapstacks: data normalization and layered color layer loading
- Hosting service and SASE, enjoy the integration of network and security | phase I review
- Combination mode -- stock speculation has been cut into leeks? Come and try this investment strategy!
- Docker deploy mysql5.7
猜你喜欢

宅男救不了元宇宙

天天鉴宝暴雷背后:拖欠数千万、APP停摆,创始人预谋跑路?

16 excellent business process management tools

Bean lifecycle flowchart

使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value

顺序栈1.0版本

Agency mode -- Jiangnan leather shoes factory

"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"

Variable setting in postman

Map跟object 的区别
随机推荐
Leetcode(455)——分发饼干
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
基于SSM的物料管理系统(源码+文档+数据库)
基于QT+MySQL的相机租赁管理系统
在Dialog中使用透明的【X】叉叉按钮图片
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
The difference between RPC and restful
《梦华录》“超点”,鹅被骂冤吗?
After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
Basic operation of sequence table
Leetcode (455) - distribute cookies
消息称腾讯正式宣布成立“XR”部门,押注元宇宙;谷歌前 CEO:美国即将输掉芯片竞争,要让台积电、三星建更多工厂...
Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable
DX12引擎开发课程进度-这个课程到底讲到哪里了
伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
You can capture fingerprints with a mobile camera?! Accuracy comparable to signature and monogram, expert: you are aggravating discrimination
全上链哈希游戏dapp系统定制(方案设计)
Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
二叉树的基本性质与遍历
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