【问题标题】:Junit test a class with a bunch of @PointcutJunit 用一堆@Pointcut 测试一个类
【发布时间】:2019-05-04 06:35:22
【问题描述】:

是否有一种优雅的方式来对以下类进行单元测试?

public class PointCuts {
    @Pointcut(value = "execution(* com.eg.app..*.*(..))")
    public void all() {
    }
    @Pointcut(value = "execution(* com.eg.app.service.advice..*.*(..))")
    public void log() {
    }
    @Pointcut(value = "execution(* com.eg.app.service.auth..*.*(..))")
    public void auth() {
    }
    @Pointcut(value = "execution(* com.eg.app.setup.auth..*.*(..))")
    public void authtest() {
    }
    @Pointcut(value = "all() && !log() && !auth() && !authtest()")
    public void app() {
    }
    @Pointcut(value = "execution(* com.eg.app.repo.CustomerRepo.save(..))")
    public void saveCustomer() {
    }
}

【问题讨论】:

    标签: spring junit aop aspect pointcut


    【解决方案1】:

    测试这个切入点列表是没有意义的,因为没有建议(之前、之后或周围),它们不会做任何事情。所以你要测试的是使用这些切入点的建议。

    【讨论】:

      猜你喜欢
      • 2011-01-30
      • 2020-09-19
      • 2015-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多