in build.gradle
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
}
Code
import com.myapp.LVActivity;
import org.junit.Test;
import static org.junit.Assert.*;
public class DeviceUnitTest {
@Test
public void check_that_is_correct_device_name_isTrue() {
assertThat(LVActivity.isCorrectDevice("MySpecialDevice"), is(true));
}
}
In LVActivity:
private final static String correctName = "MySpecialDevice";
public static boolean isCorrectDevice(String deviceName) {
return deviceName.equals(correctName);
}
The error is here:
is(true)
Error:
Cannot resolve method is(boolean)
I am trying to do a simple local unit test.
I'm following this tutorial http://developer.android.com/training/testing/unit-testing/local-unit-tests.html
Wouldn't you rather just say:
import static org.junit.Assert.*;
assertTrue(LVActivity.isCorrectDevice("MySpecialDevice"));
This is a more natural expression for checking a boolean.
But if you need to use the is matcher with assertThat, you will need this import:
import static org.hamcrest.CoreMatchers.*;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With