Have been using @Rule
from junit
using 4.12
. But today updated to 4.5
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
</dependency>
Getting error on compiling the code on
@Rule
public TestName name = new TestName();
package org.junit.rules does not exist
cannot find symbol [ERROR] symbol: class Rule [ERROR] location: package org.junit
Has this been removed? Any alternatives to it?
Moving from version 4.12
to 4.5
feels more like downgrading than updating.
@Rule
was introduced in 4.7
version of junit
, thus it cannot be found.
Now the most stable version of junit
is 4.12
, at least this is the latest one that you could find in maven repository . However, junit5 was introduced on 7.7.2016 and you could use it if you apply this dependency:
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-api</artifactId>
<version>5.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.