Whenever I run a simple JUnit test on Android studio, the tests always succeed no matter what..
I already hit Build Variant and this is under Unit Tests.
public class ECUserTests extends InstrumentationTestCase{
public void test() throws Exception{
final int expected = 1;
final int reality = 5;
assertEquals(expected, reality);
}
I added
testOptions {
unitTests.returnDefaultValues = true
}
To my build.gradle file and now this is something that clearly isn't true is returning as passed.
For the new unit test support, you don't need to inherit from InstrumentationTestCase
, but you do need to annotate your test method.
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ECUserTests {
@Test
public void test() {
final int expected = 1;
final int reality = 5;
assertEquals(expected, reality);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.