Cannot resolve symbol assertThat
12,003
Solution 1
Make sure you imported assertThat.
public static <T> void assertThat(T actual,
org.hamcrest.Matcher<T> matcher)
import static org.hamcrest.MatcherAssert.assertThat;
Then Clean-Rebuild-Run .
Solution 2
I had the same problem. Here follows what worked to me:
At app/build.gradle:
testImplementation 'com.google.truth:truth:0.43'
At EmailValidatorTest class:
import com.google.common.truth.Truth;
and inside emailValidator_simpleEmail_returnsTrue() method:
Truth.assertThat(EmailValidator.isValidEmail("[email protected]"),is(true))
See, you don't import 'assertThat' directily, oposite to what is said in the tutorial.
Author by
Android
Updated on June 08, 2022Comments
-
Android about 2 years
I have the following dependencies in my
build.gradle
filetestCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.9.5'
And my test class
EmailValidatorTest
has the following code@Test public void emailValidator_simpleEmail_returnsTrue(){ assertThat(EmailValidator.isValidEmail("[email protected]"),is(true)) }
But i get the error as
Cannot resolve symbol assertThat
. I get onlyassert
object .I'm currently working on a sample fromAndroid Developers
i,e :https://github.com/googlesamples/android-testing/tree/master/unit/BasicSample
.