测试运行失败:仪器仪表运行失败,原因是“抛出java.lang.ClassNotFoundException” [英] Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'

查看:624
本文介绍了测试运行失败:仪器仪表运行失败,原因是“抛出java.lang.ClassNotFoundException”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次设立 Android的测试项目来测试 Android项目

This is my first time setting up an android test project to test a android project.

我已经创建了一个非常基本的测试案例,我正在努力去跑,但是我有什么不运行。我得到一个测试运行失败:仪器仪表运行失败,原因是抛出java.lang.ClassNotFoundException

I've created a very basic test case which I'm trying to get to run, however what I have does not run. I get a Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'.

我会troubleshot这个多了,但我没有得到任何更多的信息,如哪些类是试图找到等对如何从错误的详细信息,任何想法?可能需要的任何公用地方我应该看看,或任何可配置的,我俯瞰?

I would troubleshot this more, however I don't get any more information, such as which class it is trying to find, etc. Any ideas on how to get more information from the error? Any common areas I should look at, or anything that might need to be configured that I'm overlooking?

下面是从控制台的信息:

Below is the information from the console:

[2013-04-16 13:21:49 - XyzProgramTest] Android Launch!
[2013-04-16 13:21:49 - XyzProgramTest] adb is running normally.
[2013-04-16 13:21:49 - XyzProgramTest] Performing android.test.InstrumentationTestRunner JUnit launch
[2013-04-16 13:21:49 - XyzProgramTest] Automatic Target Mode: launching new emulator with compatible AVD 'GalaxyNexusAPI_17'
[2013-04-16 13:21:49 - XyzProgramTest] Launching a new emulator with Virtual Device 'GalaxyNexusAPI_17'
[2013-04-16 13:21:53 - Emulator] extension WGL_ARB_make_current_read was not found
[2013-04-16 13:21:53 - Emulator] extension WGL_EXT_swap_control was not found
[2013-04-16 13:21:53 - Emulator] Failed to create pbuf surface for FB 0x3004
[2013-04-16 13:21:53 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 13:21:54 - XyzProgramTest] New emulator found: emulator-5554
[2013-04-16 13:21:54 - XyzProgramTest] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 13:22:55 - XyzProgramTest] HOME is up on device 'emulator-5554'
[2013-04-16 13:22:55 - XyzProgramTest] Uploading XyzProgramTest.apk onto device 'emulator-5554'
[2013-04-16 13:22:55 - XyzProgramTest] Installing XyzProgramTest.apk...
[2013-04-16 13:23:57 - XyzProgramTest] Success!
[2013-04-16 13:23:57 - XyzProgramTest] Project dependency found, installing: XyzProgram
[2013-04-16 13:23:57 - XyzProgram] Uploading XyzProgram.apk onto device 'emulator-5554'
[2013-04-16 13:23:58 - XyzProgram] Installing XyzProgram.apk...
[2013-04-16 13:24:05 - XyzProgram] Success!
[2013-04-16 13:24:05 - XyzProgramTest] Launching instrumentation android.test.InstrumentationTestRunner on emulator-5554
[2013-04-16 13:24:07 - XyzProgramTest] Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'


其他注意事项:

在我的 Android的测试项目,我创建了一个简单的测试,类似于匹配了带班,我想测试我的<$包一包C $ C> Android项目。因此,像 com.company.android.projectname 。我在 Android的测试项目中指定该 清单文件的仪器仪表部分。

In my android test project, I created a simple test with a package similar to the package that matches up with the class I'm trying to test in my android project. So something like com.company.android.projectname. I've specified this in the android test project manifest file's instrumentation section.

<instrumentation
    android:name="android.test.InstrumentationTestRunner"
    android:targetPackage="com.company.android.projectname" />

当我改变了这种匹配的是,我得到一个新的错误,指出测试运行失败:无法找到仪器仪表目标包:com.company.android.projectname

When I changed this to match that, I get a new error that says Test run failed: Unable to find instrumentation target package: com.company.android.projectname

我不是100%肯定这是什么 targetPackage 应该是,如果我需要多个仪器仪表为每个包我想测试等。当我将它设置为 com.company.android 这是当我得到的抛出java.lang.ClassNotFoundException 。任何建议将是AP preciated,在此期间,我会继续我的努力,这出在我自己的。

I'm not 100% sure what that targetPackage should be and if I need multiple instrumentations for each package I want to test, etc. When I set it to com.company.android that is when I get the java.lang.ClassNotFoundException. Any suggestions would be appreciated, in the meantime I'll continue my efforts to figure this out on my own.

推荐答案

想通了我的问题,我发布文档目的答案...

Figured out my issue and am posting the answer for documentation purposes...

我的问题的根源是两个不同的东西:

The root of my problem was 2 different things:

  1. 在我做了一些重构,它改变的位置我 android.app.Application 类和我的活动。这使得它,所以我的 因为我需要更新我的表现在主程序中是行不通的我 Android项目
  2. 让我的Andr​​oid项目的更新,以我的表现后,我不得不让我的 Android的测试项目中的某些更新来指向扩展的类的更新的位置 android.app.Application
  1. I did some refactoring, which change the location of my android.app.Application class and my activities. This made it so my main program was not working as I needed to update my manifest in my android project.
  2. After making the updates to my manifest in my android project, I had to make some updates in my android test project to point to the updated location of the class that extends android.app.Application.

之后,做了一些清洗并重新测试,一切都一帆风顺。

After that, did some cleans and tested again and things were good.

这篇关于测试运行失败:仪器仪表运行失败,原因是“抛出java.lang.ClassNotFoundException”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆