Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
andyalgorithm
toBeTopJavaer
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
toBeTopJavaer
/
docs
/
basics
/
java-basic
/
junit.md
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
18 lines (13 loc) · 1.5 KB
master
Breadcrumbs
toBeTopJavaer
/
docs
/
basics
/
java-basic
/
junit.md
Copy path
Top
File metadata and controls
Code
Blame
18 lines (13 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
JUnit是一个Java语言的单元测试框架
。
它由肯特·贝克和埃里希·伽玛
(
Erich
Gamma
)
建立
,
逐渐成为源于Kent
Beck的sUnit的xUnit家族中为最成功的一个
。
JUnit有它自己的JUnit扩展生态圈
。
JUnit
促进了
“
先测试后编码
”
的理念
,
强调建立测试数据的一段代码
,
可以先测试
,
然后再应用
。
这个方法就好比
“
测试一点
,
编码一点
,
测试一点
,
编码一点
……”,
增加了程序员的产量和程序的稳定性
,
可以减少程序员的压力和花费在排错上的时间
。
特点
:
*
JUnit
是一个开放的资源框架
,
用于编写和运行测试
。
*
提供注释来识别测试方法
。
*
提供断言来测试预期结果
。
*
提供测试运行来运行测试
。
*
JUnit
测试允许你编写代码更快
,
并能提高质量
。
*
JUnit
优雅简洁
。
没那么复杂
,
花费时间较少
。
*
JUnit
测试可以自动运行并且检查自身结果并提供即时反馈
。
所以也没有必要人工梳理测试结果的报告
。
*
JUnit
测试可以被组织为测试套件
,
包含测试用例
,
甚至其他的测试套件
。
*
JUnit
在一个条中显示进度
。
如果运行良好则是绿色
;
如果运行失败
,
则变成红色
。
JUnit知识经常
和测试驱动开发的讨论融合在一起
。
可以参考Kent
Beck的
《
Test
-
Driven
Development
:
By
Example
》
一书
(
有中文版和影印版
)。
推荐一份JUnit的教程
,
可以帮助你快速的学习使用它
:
https
:
//wiki.jikexueyuan.com/project/junit/
You can’t perform that action at this time.