androidrestapi自动化测试
我已经使用wiremock作为示例应用程序进行了API测试,如下面的代码所示。但是我得到了如下所示的numberFormat异常和invalide int。这个错误请给我任何建议androidrestapi自动化测试,android,android-instrumentation,Android,Android Instrumentation,我已经使用wiremock作为示例应用程序进行了API测试,如下面的代码所示。但是我得到了如下所示的numberFormat异常和invalide int。这个错误请给我任何建议 @RunWith(AndroidJUnit4.class) public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> { public MainActivityTest() {
@RunWith(AndroidJUnit4.class)
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
public MainActivityTest()
{
super(MainActivity.class);
}
@Override
@Before
public void setUp() throws Exception
{
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
getActivity();
}
private static void stubServerCall() throws Exception
{
//WireMock.configureFor(Integer.parseInt(serverURL));
WireMock.configureFor(Integer.parseInt("http://androidexample.com/media/webservice/JsonReturn.php"));
stubFor(get(urlEqualTo("/tree/getLocalePack"))
.willReturn(aResponse()
.withStatus(HttpStatus.ORDINAL_200_OK)
.withHeader("Content-Type", "text/xml")
.withBody("<response>This is mock response</response>")));
}
@Test
public void testSendRequestEspresso() throws Exception
{
stubServerCall();
onView(withId(R.id.returnStringLbl)).check(matches(withText("Nothing yet returned")));
onView(withId(R.id.sendRequest)).perform(click());
}
}
您传递的参数似乎存在一些问题。这些参数是什么请给我建议…我看不到任何参数。我认为它直接命中了一个Url。您的行是什么java:137,如可用日志中所示。检查以下示例:运行测试$adb shell am instrument-w-r-e debug false-e class com.example.prashant.apitry.handstandsam.httpmocking.tests.RealServerTest.com.example.prashant.apitry.test/android.support.test.runner.AndroidJUnitRunner客户端尚未就绪。。开始运行测试测试运行失败:由于“java.lang.NoClassDefFoundError”测试套件为空,检测运行失败。