'I can't import the containsString CoreMatcher from hamcrest
I'm trying to do the following:
import static org.hamcrest.CoreMatchers.containsString
assertThat(myvar, containsString("string to check"))
Here are my dependencies. I need to support junit 4 and junit 5
testCompile('org.mockito:mockito-all:+')
testCompile('org.mockito:mockito-inline:+')
// use junpiter
testImplementation(platform('org.junit:junit-bom:+'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('org.junit.jupiter:junit-jupiter-params')
// AND junit 4 because I use a test framework that has a hard dependency on junit 4
testImplementation("junit:junit:4.13")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.2")
// Trying to pull in latest hamcrest
testImplementation('org.hamcrest:hamcrest:2.2')
The problem is in my class when I to import static org.hamcrest.CoreMatchers.containsString It appears to be using hamcrest 1.3 which does not have "containsString". Is it using 1.3 because junit 4 depends on this version of hamcrest?
Is what I'm trying to do impossible because I'm pulling in both junit 4 and jupiter?
EDIT
In my editor it says it does not exist:

Using my IDE I can read its docs on my localhost: (http://localhost:63342/..../hamcrest-core-1.3-javadoc.jar/org/hamcrest/CoreMatchers.html)
When trying to run it I get this error
No signature of method: src.myproject.MyClassTest.containsString() is applicable for argument types: (String) values: [string to check]
groovy.lang.MissingMethodException: No signature of method: src.myproject.MyClassTest.containsString() ....
Per comments I can see now it looks like its using CoreMatchers from mockito for some reason:

EDIT Solution
Per comments the issue was that CoreMatchers was coming from mockito. I have removed mockito as a dependency and deleted its jars and that fixed it.
But I still don't understand how/why this was happening. I hope a proper answer to my question will include an explanation of why CoreMatchers was being fetched from the wrong place.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

