开发者

Android: NoClassDefFoundError upon Android JUnit Test

开发者 https://www.devze.com 2023-04-09 18:44 出处:网络
JUnit trace: java.lang.NoClassDefFoundError: com.sample.Functions$Floor at com.sample.test.FunctionsTest.testValidateLocation(FunctionsTest.java:289)

JUnit trace:

java.lang.NoClassDefFoundError: com.sample.Functions$Floor
at com.sample.test.FunctionsTest.testValidateLocation(FunctionsTest.java:289)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

Here's my test code:

public class FunctionsTest extends TestCase {
    public void testValidateLocation() {
        location.setLatitude(-90);
        location.setLongitude(-180);
        assertTrue(Functions.Location.validateLocati开发者_运维问答on(location));
    }
}

Here's the target method:

public static boolean validateLocation(android.location.Location location) {
    return location==null?false:Double.compare(location.getLatitude(), MAXIMUM_LATITUDE) <= 0
            && Double.compare(location.getLatitude(), MINIMUM_LATITUDE) >= 0
            && Double.compare(location.getLongitude(), MAXIMUM_LONGITUDE) <= 0 
            && Double.compare(location.getLongitude(), MINIMUM_LONGITUDE) >= 0;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消