2019.03.04(java中的JUnit)

在pom.xml配置文件中添加依赖

	<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>

@before和@Test和@After运行顺序

代码测试

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class Test1 {

    @Before
    public void be(){
        System.out.println("before");
    }

    @After
    public void af(){
        System.out.println("after");
    }

    @Test
    public void test(){
        System.out.println("a");
    }
}

运行结果(注意观察运行顺序)
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_34191426/article/details/88128880
今日推荐