我有已集成到 Hudson 中的 android 测试项目。我创建了一个具有以下设置的自由风格软件项目: 1.源代码管理- 自定义工作区 2.在构建期间运行 Android 模拟器: * Android OS 版本:4.0.3 * 屏幕密度:240 * 屏幕分辨率:WVGA * 设备语言环境:en_US * SD 卡大小:16M 3.调用 Ant:目标:all clean emma debug install test 构建文件:workspace/Project/build.xml 4.构建后操作 * 归档工件:**/*test-TEST .xml * 发布 JUnit 测试结果报告:**/*test-TEST.xml * 记录 Emma 覆盖率报告:**/coverage.xml * 记录文件指纹以跟踪使用情况:**/*test-TEST.xml 这是构建.xml 文件部分涵盖了我的 ant 目标:
<!-- version-tag: custom -->
<target name="test" depends="-test-project-check"
description="Runs tests from the package defined in test.package property">
<property name="tested.project.absolute.dir" location="${tested.project.dir}" />
<property name="test.runner" value="android.test.InstrumentationTestRunner" />
<!-- Application package of the tested project extracted from its manifest file -->
<xpath input="${tested.project.absolute.dir}/AndroidManifest.xml"
expression="/manifest/@package" output="tested.manifest.package" />
<xpath input="AndroidManifest.xml"
expression="/manifest/@package" output="manifest.package" />
<property name="emma.dump.file"
value="/data/data/${tested.manifest.package}/coverage.ec" />
<if condition="${emma.enabled}">
<then>
<echo>WARNING: Code Coverage is currently only supported on the emulator and rooted devices.</echo>
<run-tests-helper emma.enabled="true">
<extra-instrument-args>
<arg value="-e" />
<arg value="coverageFile" />
<arg value="${emma.dump.file}" />
</extra-instrument-args>
</run-tests-helper>
<echo>Downloading coverage file into project directory...</echo>
<exec executable="${adb}" failonerror="true">
<arg line="${adb.device.arg}" />
<arg value="pull" />
<arg value="${emma.dump.file}" />
<arg value="coverage.ec" />
</exec>
<echo>Extracting coverage report...</echo>
<emma>
<report sourcepath="${tested.project.absolute.dir}/${source.dir}"
verbosity="${verbosity}">
<!-- TODO: report.dir or something like should be introduced if necessary -->
<infileset dir=".">
<include name="coverage.ec" />
<include name="coverage.em" />
</infileset>
<!-- TODO: reports in other, indicated by user formats -->
<html outfile="${basedir}/coverage/coverage.html" />
<xml outfile="${basedir}/coverage/coverage.xml" />
</report>
</emma>
<echo>Cleaning up temporary files...</echo>
<delete file="coverage.ec" />
<delete file="coverage.em" />
<echo>Saving the report file in ${basedir}/coverage/coverage.html</echo>
</then>
<else>
<run-tests-helper />
</else>
</if>
<mkdir dir="${basedir}/junit-results" />
<echo>Base dir is ${basedir}</echo>
<exec executable="${adb}" failonerror="true" dir="${basedir}/junit-results">
<arg line="${adb.device.arg}" />
<arg value="pull" />
<arg value="/data/data/${tested.manifest.package}/files/" />
</exec>
</target>
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
现在,这个项目工作正常,我得到了 emma 覆盖率和测试结果,但是当我用相同的选项配置多配置项目时,除了 android 模拟器,我用 os、密度和屏幕分辨率设置了不同的变量,我被一个卡住了错误 -
test:
[echo] WARNING: Code Coverage is currently only supported on the emulator and rooted devices.
[echo] Running tests ...
[exec]
[exec] com.mobclix.android.externaltestharness.test.UnitActivityTest:.
[exec] Test results for PolideaInstrumentationTestRunner=.
[exec] Time: 25.122
[exec]
[exec] OK (1 test)
[exec]
[exec]
[exec] Generated code coverage data to /data/data/com.mobclix.android.externaltestharness/coverage.ec
[echo] Downloading coverage file into project directory...
[exec] 355 KB/s (2043 bytes in 0.005s)
[echo] Extracting coverage report...
[echo] Cleaning up temporary files...
[delete] Deleting: /Users/biercoff/Work/Workspace/HarnessExternalTest/coverage.ec
[delete] Deleting: /Users/biercoff/Work/Workspace/HarnessExternalTest/coverage.em
[echo] Saving the report file in /Users/biercoff/Work/Workspace/HarnessExternalTest/coverage/coverage.html
[echo] Base dir is /Users/biercoff/Work/Workspace/HarnessExternalTest
[exec] pull: building file list...
[exec] pull: /data/data/com.mobclix.android.externaltestharness/files/com.mobclix.android.externaltestharness.test-TEST.xml -> ./com.mobclix.android.externaltestharness.test-TEST.xml
[exec] 1 file pulled. 0 files skipped.
[exec] 40 KB/s (499 bytes in 0.012s)
BUILD SUCCESSFUL
Total time: 1 minute 20 seconds
$ /Users/biercoff/.hudson/tools/android-sdk/platform-tools/adb disconnect localhost:53830
[android] Stopping Android emulator
[android] Archiving emulator log
$ /Users/biercoff/.hudson/tools/android-sdk/platform-tools/adb kill-server
Recording fingerprints
Recording test results
No test report files were found. Configuration error?
Archiving artifacts
Description set:
Emma: looking for coverage reports in the provided path: /Users/biercoff/Work/Workspace/HarnessExternalTest/coverage/coverage.xml
Emma: found 1 report files:
/Users/biercoff/Work/Workspace/HarnessExternalTest/coverage/coverage.xml
Emma: stored 1 report files in the build folder: /Users/biercoff/.hudson/jobs/MulitTestHarnessProject/configurations/axis-density/240/axis-os/4.0.3/axis-resolution/WVGA/builds/2012-05-18_17-26-05/emma
Emma: Coverage: Classes 21/39 (54%). Methods 40/128 (31%). Blocks 833/2928 (28%). Lines 154.5/528 (29%).
[DEBUG] Skipping watched dependency update for build: MulitTestHarnessProject/density=240,os=4.0.3,resolution
对于 emma 覆盖率,我不得不将 Hudson 中的路径更改为 /Users/biercoff/Work/Workspace/HarnessExternalTest/coverage/coverage.xml 以使其工作,但是当我尝试对 Junit 测试结果做同样的事情时,Hudson 拒绝“看见。文件位于 junit-results 文件夹下的项目文件夹中,但每次我运行新构建时,我都会得到相同的没有找到测试报告文件。配置错误?错误信息。尝试了许多变化,但没有运气。我可能错过了一些非常小的东西。有人可以帮我吗?