Junit4学习之套件测试

Junit4学习之套件测试
时隔N月,再一次看到了Junit测试,就看了看,熟悉了套件(SUITE)测试

这个非常的好理解,首先需要建立一个空的测试类

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)//A
@Suite.SuiteClasses({Test1.class,Test2.class,Test3.class})//B
public class SuitTest {
}

这个必须是空的,不需要写其他的代码
A、处指定运行器,“告诉”编译器,这个文件是用来套件测试的
B、处是以数组的方式添加测试类,想要测试哪一个就添加哪一个类
再来新建三个测试类Test1,Test2,Test3

import org.junit.Test;

public class Test1 {
    @Test
    public void test() {
        System.out.println("this is test1");
    }
}

剩下的代码没有贴

写完之后将类添加到套件测试类里,然后右键“Run As”—>”Junit Test”
可以在控制台看到输出

this is test1
this is test2
this is test3

套件测试可以捆绑几个单元测试用例并一起运行它,方便了管理,简单易懂!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值