junit5坑: mvn构建不执行注解

junit5本地run单个是没问题的,放到jenkins上面mvn执行,注解一直没有生效。

本来以为是代码的方法写错了,排查后是mvn 执行的时候没有跑@BeforeAll注解。

解决办法就是把junit engine和junit api放到dependency里面。

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.7.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.0-M1</version>
            <scope>test</scope>
        </dependency>

  

 

题外话:beforeAll只针对单个的类,不针对所有类。

 

posted @ 2020-08-03 14:41  头鹰在学习  阅读(527)  评论(0编辑  收藏  举报