嗨,我是单元测试的新手。我正在为一个库项目编写单元测试用例。我的库仅包含异步网络调用。我曾尝试使用robotium 和android 仪器框架来编写测试用例。我收到以下错误
----- begin exception -----
I/TestRunner( 1578):
I/TestRunner( 1578): junit.framework.AssertionFailedError: Add result should be 100 but was 80
I/TestRunner( 1578): at junit.framework.Assert.fail(Assert.java:50)
I/TestRunner( 1578): at junit.framework.Assert.assertTrue(Assert.java:20)
I/TestRunner( 1578): at com.mamlambo.article.simplecalc.test.MathValidation.test1AddDecimalValues(MathValidation.java:66)
I/TestRunner( 1578): at java.lang.reflect.Method.invokeNative(Native Method)
I/TestRunner( 1578): at java.lang.reflect.Method.invoke(Method.java:511)
I/TestRunner( 1578): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
I/TestRunner( 1578): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
I/TestRunner( 1578): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
I/TestRunner( 1578): at junit.framework.TestCase.runBare(TestCase.java:134)
I/TestRunner( 1578): at junit.framework.TestResult$1.protect(TestResult.java:115)
I/TestRunner( 1578): at junit.framework.TestResult.runProtected(TestResult.java:133)
I/TestRunner( 1578): at junit.framework.TestResult.run(TestResult.java:118)
I/TestRunner( 1578): at junit.framework.TestCase.run(TestCase.java:124)
I/TestRunner( 1578): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
I/TestRunner( 1578): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
I/TestRunner( 1578): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
I/TestRunner( 1578): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
I/TestRunner( 1578): ----- end exception -----
每当条件失败时,例如:assertTrue(false)
并且执行突然停止。它必须执行其他测试用例对吗?或者我做错了什么请帮忙。
这是我的测试用例
public void test1AddDecimalValues() {
String mathResult = "80";
assertTrue("Add result should be " + "100" + " but was "
+ mathResult, mathResult.equals("100"));
}