标签 junit 下的文章

package junit;

import static org.junit.Assert.*;

import org.junit.*;

/**
 * Created by guoli on 2017/4/18 0018.
 * aW1laWxpZ2VAZ21haWwuY29tCiAgICAgcXE6Mjg5MTY4NTEKICAgIHpoYW5nZ3VvbGkuY24=
 */
public class FlowTest {

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        System.out.println("BeforeClass...");
    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {
        System.out.println("AfterClass...");
    }

    @Before
    public void setUp() throws Exception {
        System.out.println("Before...");
    }

    @After
    public void tearDown() throws Exception {
        System.out.println("After...");
    }

    @Test
    public void test1() throws Exception {
        System.out.println("test1.....");
    }

    @Test
    public void test2() throws Exception {
        System.out.println("test2.....");
    }
}

- 阅读剩余部分 -

测试用例是用来验证达到预期结果,但不检查逻辑错误;测试用例不是用来证明你是对的,而是用来证明你没有错.

Maven:

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

在junit包下新建Cal计算类

package junit;

public class Cal {
    public int add(int a, int b) {
        return a + b;
    }
}

新建JUnit的测试类CalTest

- 阅读剩余部分 -