如何为一个空的函数切点编写JUnit测试

huangapple go评论57阅读模式
英文:

How do you write a JUnit test for an empty function Pointcut

问题

我正在尝试为这个方法编写一个JUnit测试。我对Pointcut不太熟悉。有什么建议吗?

 /**
     * 匹配所有repositories、services和Web REST endpoints的切入点。
     */
    @Pointcut("within(@org.springframework.stereotype.Repository *)" +
        " || within(@org.springframework.stereotype.Service *)" +
        " || within(@org.springframework.web.bind.annotation.RestController *)")
    public void springBeanPointcut() {
        // 由于这只是一个切入点,所以方法是空的,具体实现在advices中。
    }
英文:

I am trying to write a JUnit test for this method. I am not familiar with Pointcut. Any advice?

 /**
     * Pointcut that matches all repositories, services and Web REST endpoints.
     */
    @Pointcut("within(@org.springframework.stereotype.Repository *)" +
        " || within(@org.springframework.stereotype.Service *)" +
        " || within(@org.springframework.web.bind.annotation.RestController *)")
    public void springBeanPointcut() {
        // Method is empty as this is just a Pointcut, the implementations are in the advices.
    }

答案1

得分: 1

只需创建一个新的测试,并让它调用 springBeanPointcut() 函数。

英文:

Just make a new test and have it call springBeanPointcut()

huangapple
  • 本文由 发表于 2020年8月22日 06:12:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63530656.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定