JUnit5认识

第一步安装最新的eclipse2017

最新的eclipse才支持JUnit5,我的eclipse2016不行了。果断换,http://www.eclipse.org/ 主页就是炫。

第二步 JUnit5官网

http://junit.org/junit5/docs/current/user-guide/ 官网的资料永远是最新的,最全的。这需要你英语要好点。
贴代码

<dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.0.1</version>
        <scope>test</scope>
     </dependency>
     <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.0.1</version>
        <scope>test</scope>
     </dependency>
     <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>4.12.1</version>
        <scope>test</scope>
     </dependency>
import static org.junit.jupiter.api.Assertions.assertTrue;  
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

class FirstJUnit5Tests {

    @Test
    void myFirstTest() {
        assertEquals(2, 1 + 1);
    }

    @Test  
    void standardAssertions() {  
        assertEquals(2, 2);  
        assertEquals(4, 4, "The optional assertion message is now the last parameter.");  
        assertTrue(2 == 2, () -> "Assertion messages can be lazily evaluated -- "  
                + "to avoid constructing complex messages unnecessarily.");  
    }  
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值