小编tyl*_*rgo的帖子

@BeforeClass 和 @AfterClass 在每次测试之前和之后调用

我有一个非常简单的测试类,用于在 Android 上运行 espresso 测试,如下所示:

import android.util.Log;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.IOException;

@RunWith(JUnit4.class)
public class Wtf {

    private static class TestResources extends ExternalResource {
        protected void before() {
            println("before() TestResources");
        }
        protected void after() {
            println("after() TestResources");
        }
    }

    @ClassRule
    public static final TestResources res = new TestResources();

    @BeforeClass
    public static void setUpClass() {
        println("@BeforeClass setUpClass()");
    }

    @AfterClass
    public static void tearDownClass() throws IOException { …
Run Code Online (Sandbox Code Playgroud)

java junit android junit4 android-espresso

1
推荐指数
1
解决办法
3471
查看次数

标签 统计

android ×1

android-espresso ×1

java ×1

junit ×1

junit4 ×1