The import org.hamcrest.Matchers.hasProperty
cannot be resolved in JUnit4.12.
What is the alternative to use hasProperty
?
The import org.hamcrest.Matchers.hasProperty
cannot be resolved in JUnit4.12.
What is the alternative to use hasProperty
?
Hamcrest is not embedded in JUnit 4.12, instead you'll need to include the separate Hamcrest library on your classpath.
If you are using Maven you can do this by including the following dependency in your pom.xml
:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
Alternatively you can download the JAR from Maven Central.
In case you only need it for UnitTests you can use following dependency (works with JUnit5 as well):
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<version>2.0.0.0</version>
<scope>test</scope>
</dependency>
Use this import if you are not able to use the hamcrest "equalTo" method.
import static org.hamcrest.Matchers.equalTo;
body("scope", equalTo("APP"));
© 2022 - 2024 — McMap. All rights reserved.
testImplementation org.hamcrest:hamcrest:2.2
– Mongol