如何使用robotium生成测试结果报告?
我一直在使用 Robotium 来测试我的 Android 应用程序。测试成功,但我想知道是否有任何方法可以在单独的文件中查看测试结果。
I have been using robotium to test my android application.Testing was successful but i want to know that is there any way to view test results in a separate file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我很幸运,只是将 robotsium 测试作为常规 Android JUnit 测试运行,然后使用标准机制获取测试结果,即 ant 任务 fetch-test-report。为此,我使用了 android 通过工具创建的 build.xml 文件。有关设置的详细说明,请参阅在其他 IDE 中进行开发的文档。祝你好运!
I have had good luck just running the robotium tests as regular Android JUnit tests, and then using the standard mechanism to get back the test results, namely the ant task fetch-test-report. To do this I used the build.xml file create by android through the tooling. See documentation for developing in other IDEs for detailed instructions on setting that up. Good luck!
当我们使用 Eclipse IDE 时,XML 报告生成非常简单
要遵循的步骤
在 eclipse Run As 中照常运行 Junit 测试 ->Android Junit Test。
测试运行完成后,您将在 IDE 提供的状态栏中看到该状态。
当您单击 Eclipse IDE 的 Junit 视图中提供的“测试运行历史记录”图标时,您将找到“导出”选项,通过该选项您可以导出 XML 格式的测试。
如果您在查找图标时遇到问题,请观看下图。
XML report generation is quite simple when we are using Eclipse IDE
Steps to be followed
Run the Junit test as usual in eclipse Run As->Android Junit Test.
Once the test run is completed you will be indicated with the status in the status bar provided by the IDE.
When you click on the Test Run History Icon which is available in the Junit view of eclipse IDE you will find the Export option through which you can you can export the XML format test.
If you have and problems in finding the icon please watch the below image.
我使用 logcat 和 android 类 Log.'severity'(tag, msg) 的方法('严重性'可以是 i-info、d-debug、w-warn、e-error、v-verbose),这里是一个示例单击按钮 myView:
使用过滤器,您可以按标签过滤输出并选择所有行将其保存在 .txt 文件中。所有这些您都可以通过编写简单的脚本自动完成,该脚本会将输出重定向到 InstrumentationTestRunner 的文件。
另请参阅页面:日志类、logcat
I use approach with logcat and android class Log.'severity'(tag, msg) ('severity' can be i-info, d-debug, w-warn, e-error, v-verbose), here is an example of clicking button myView:
Using filters you can filter output by tags and selecting all lines save it in .txt file. All these you can do automatically by writing simple script which will redirect output to file from InstrumentationTestRunner for you.
see also pages: Log class, logcat
就我而言,我使用 Spoon 来生成测试 html 报告。 https://github.com/square/spoon
In my case, I user spoon to generate test html reports. https://github.com/square/spoon
您可以按照您选择的方式进行操作,因为它不是纯 junit 代码:
1-使用任何 xml 编写/解析 api 的基于 XML 的测试执行报告
2-使用日志的基于 logcat 的测试执行报告,例如,如果您使用 Eclipse IDE
3-自定义报告写入被测设备,为此,您需要 api 来写入设备。
根据您的要求和 IDE,这是可用的几种方法中的三种。
You can follow the way of your choice because it is not pure junit code:
1-XML based test execution report using any xml writing/parsing apis
2-logcat based test execution report using logs for example if you are using Eclipse IDE
3-customized report writing to your device under test, for this you will need apis to write to device
These are three ways out of several available as per your requirements and IDE.
您可以使用PolideainstrumentationtestRunner,它允许您准确指定要存储测试结果的位置。 (添加选项 junitXmlOutput true 和 junitOutputDirectory yourPath)
http:// /code.google.com/p/the-missing-android-xml-junit-test-runner/
我希望它会有所帮助。
You can use the PolideainstrumentationtestRunner, it allows you to specify exactly where you want to store the test result. (add option junitXmlOutput true and junitOutputDirectory yourPath)
http://code.google.com/p/the-missing-android-xml-junit-test-runner/
I hope it will help.