如何检查@Before是否正在使用play框架

Ara*_*asu 1 annotations playframework

我正在运行播放应用程序.

我有

import org.junit.Before;
public class Frontpage extends Controller {
    @Before
    private static void commonData() {
            Map cacheMap = Cache.get("login_det",Map.class);
            System.out.println("commonData");
            if(cacheMap!=null)
            {
             renderArgs.put("login_det", cacheMap);
             System.out.println("renderArgs"+renderArgs.toString());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是commonData永远不会在我的控制台中打印出来.我如何检查@Before是否有效

Rom*_*las 6

您正在使用org.junit.Before注释,JUnit 使用该注释在单元测试执行之前运行方法.

在您的情况下,您应该使用play.mvc.Before注释.