# junit4
**Repository Path**: xi-jun/junit4
## Basic Information
- **Project Name**: junit4
- **Description**: 测试学习
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-10-11
- **Last Updated**: 2024-10-11
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Junit4
Junit4官网:
#### 1.介绍
该模块是针对JUnit 4的学习。
测试在开发中占据着重要地位,测试用例尽可能的覆盖业务场景,帮助实现功能自测。
同时项目随着时间的腐化,重构的过程需要完善的测试用例来保障重构,同时修改代码后避免重复手动测试。
测试需要做到以下几种条件:
1. 测试集尽可能多的覆盖业务场景
2. 测试集可以反复执行
3. 测试需要和代码同时备份以便后续重构时使用
#### 2. Junit学习
##### 2.1 开始
1. 引入依赖
```
junit
junit
test
```
##### 2.2 基本操作
1. RunWith注解
`org.junit.runner.RunWith` 是JUnit 4的一个注解,它用于指定运行测试用例的JUnit运行器。
该注解的参数是`org.junit.runner.Runner`的子类
例如,如果你想使用JUnit 4的参数化功能,你可以使用@RunWith(Parameterized.class)注解。
这是一个使用@RunWith注解的例子:
```
@RunWith(Parameterized.class)
public class MyTest {
@Parameters
public static Collection