Closed StefMa closed 7 years ago
This is a very good task for Hacktoberfest!
I'm not sure if we can exclude it. You can get the dependnecies tree with ./gradlew :thirtyinch:dependnecies
@StefMa We just need to replace 'assertEquals' and 'assertThat' by 'assertJ' right? Or anything else needs to be done?
Exactly. But assertJ isn't a method 🙃. From both, hamcrest and assertJ, the matches are assertThat
I am working on this.
But it hasn't removed hamcrest as dependency.
It is still open which dependency brings hamcrest build in.
+--- junit:junit:4.12
| \--- org.hamcrest:hamcrest-core:1.3
I tried to remove it
testCompile ("junit:junit:$junitVersion") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
Results in
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 26 more
It's not possible. https://github.com/junit-team/junit4/issues/165
Currently we have "hundreds" of different "test matchers".
assertEquals("ThirtyInch", "ThirtyInch")
assertThat("ThirtyInch", isEqualTo("ThirtyInch"))
assertThat("ThirtyInch").isEqualTo("ThirtyInch")
Each test look different. Which is bad.
We should use assertJ everywhere and get rid of the other matcher libs. To prevent using Hamcrest in the future it would be great if we can exclude it from... Don't know which dependency has hamcrest as dependency. But we have to found out it and exclude it form them if possible.