我正在尝试使用Spoon框架和 robotium solo运行 android 测试
他们的测试项目在这里找到
这是测试
package com.example.spoon.ordering.tests;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.Button;
import android.widget.CheckedTextView;
import com.robotium.solo.Solo;
import com.squareup.spoon.Spoon;
import com.example.spoon.ordering.OrderActivity;
import static org.fest.assertions.api.ANDROID.assertThat;
public class OrderActivityTest extends ActivityInstrumentationTestCase2<OrderActivity> {
public OrderActivityTest() {
super(OrderActivity.class);
}
private OrderActivity activity;
private Solo solo;
@Override protected void setUp() throws Exception {
super.setUp();
activity = getActivity();
solo = new Solo(getInstrumentation(), activity);
}
public void testMakeASandwich_ItTastesGood() {
Button nextButton = (Button) solo.getText("Next");
Spoon.screenshot(activity, "initial_state");
assertThat(nextButton).isDisabled();
solo.clickOnText("Sandwich");
Spoon.screenshot(activity, "selected_sandwich");
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "bread");
assertThat(nextButton).isDisabled();
solo.clickOnText("Wheat");
Spoon.screenshot(activity, "selected_bread");
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "meats");
assertThat(nextButton).isEnabled();
solo.clickOnText("Turkey");
solo.clickOnText("Roast Beef");
Spoon.screenshot(activity, "selected_meats");
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "veggies");
assertThat(nextButton).isEnabled();
solo.clickOnText("Lettuce");
solo.clickOnText("Tomato");
solo.clickOnText("Cucumbers");
Spoon.screenshot(activity, "selected_veggies");
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "cheeses");
assertThat(nextButton).isEnabled();
solo.clickOnText("American");
Spoon.screenshot(activity, "selected_cheeses");
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "toasted");
CheckedTextView toastedNo = (CheckedTextView) solo.getText("No");
assertThat(toastedNo).isChecked();
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "your_info");
assertThat(nextButton).isDisabled();
solo.typeText(0, "Trent Sondag");
solo.typeText(1, "bearfight@example.com");
Spoon.screenshot(activity, "completed_your_info");
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "review");
}
public void testMakeSomeSalad_ItIsHealthy() {
Button nextButton = (Button) solo.getText("Next");
Spoon.screenshot(activity, "initial_state");
assertThat(nextButton).isDisabled();
solo.clickOnText("Salad");
Spoon.screenshot(activity, "selected_salad");
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "salad_type");
assertThat(nextButton).isDisabled();
solo.clickOnText("Caesar");
Spoon.screenshot(activity, "selected_salad_type");
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "dressing");
CheckedTextView dressingNone = (CheckedTextView) solo.getText("No dressing");
assertThat(dressingNone).isChecked();
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "your_info");
assertThat(nextButton).isDisabled();
solo.typeText(0, "Trent Sondag");
solo.typeText(1, "bearfight@example.com");
Spoon.screenshot(activity, "completed_your_info");
assertThat(nextButton).isEnabled();
solo.clickOnView(nextButton);
Spoon.screenshot(activity, "review");
}
}
问题是测试因这些错误而失败,我不知道如何修复它。
08-31 14:53:47.021: I/TestRunner(12164): failed: testMakeSomeSalad_ItIsHealthy(com.example.spoon.ordering.tests.OrderActivityTest)
08-31 14:53:47.021: I/TestRunner(12164): ----- begin exception -----
08-31 14:53:47.021: I/TestRunner(12164): java.lang.VerifyError: org/fest/assertions/internal/Objects
08-31 14:53:47.021: I/TestRunner(12164): at org.fest.assertions.api.AbstractAssert.<init>(AbstractAssert.java:43)
08-31 14:53:47.021: I/TestRunner(12164): at org.fest.assertions.api.android.view.AbstractViewAssert.<init>(AbstractViewAssert.java:27)
08-31 14:53:47.021: I/TestRunner(12164): at org.fest.assertions.api.android.widget.AbstractTextViewAssert.<init>(AbstractTextViewAssert.java:14)
08-31 14:53:47.021: I/TestRunner(12164): at org.fest.assertions.api.android.widget.TextViewAssert.<init>(TextViewAssert.java:12)
08-31 14:53:47.021: I/TestRunner(12164): at org.fest.assertions.api.ANDROID.assertThat(ANDROID.java:1020)
08-31 14:53:47.021: I/TestRunner(12164): at com.example.spoon.ordering.tests.OrderActivityTest.testMakeSomeSalad_ItIsHealthy(OrderActivityTest.java:93)
08-31 14:53:47.021: I/TestRunner(12164): at java.lang.reflect.Method.invokeNative(Native Method)
08-31 14:53:47.021: I/TestRunner(12164): at java.lang.reflect.Method.invoke(Method.java:515)
08-31 14:53:47.021: I/TestRunner(12164): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
08-31 14:53:47.021: I/TestRunner(12164): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
08-31 14:53:47.021: I/TestRunner(12164): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
08-31 14:53:47.021: I/TestRunner(12164): at junit.framework.TestCase.runBare(TestCase.java:134)
08-31 14:53:47.021: I/TestRunner(12164): at junit.framework.TestResult$1.protect(TestResult.java:115)
08-31 14:53:47.021: I/TestRunner(12164): at junit.framework.TestResult.runProtected(TestResult.java:133)
08-31 14:53:47.021: I/TestRunner(12164): at junit.framework.TestResult.run(TestResult.java:118)
08-31 14:53:47.021: I/TestRunner(12164): at junit.framework.TestCase.run(TestCase.java:124)
08-31 14:53:47.021: I/TestRunner(12164): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
08-31 14:53:47.021: I/TestRunner(12164): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
08-31 14:53:47.021: I/TestRunner(12164): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
08-31 14:53:47.021: I/TestRunner(12164): at com.example.spoon.ordering.tests.SpoonInstrumentationTestRunner.onStart(SpoonInstrumentationTestRunner.java:36)
08-31 14:53:47.021: I/TestRunner(12164): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
08-31 14:53:47.021: I/TestRunner(12164): ----- end exception -----
08-31 14:53:47.025: I/TestRunner(12164): finished: testMakeSomeSalad_ItIsHealthy(com.example.spoon.ordering.tests.OrderActivityTest)
我将这些库添加到测试项目中
如何解决?