Note that there are some explanatory texts on larger screens.

plurals
  1. POnon-source-code class is included in emma xml coverage report
    primarykey
    data
    text
    <p>I am using Robotium to run UI test on Android Emulator and try to get coverage with emma. The xml coverage report is created successfully. But I found there are some classes in coverage report which are not parts of the real code. Such as.</p> <pre><code>&lt;class name="CalculatorData$Message"&gt; &lt;coverage type="class, %" value="0% (0/1)"/&gt; &lt;coverage type="method, %" value="0% (0/5)"/&gt; &lt;coverage type="block, %" value="0% (0/43)"/&gt; &lt;coverage type="line, %" value="0% (0/3)"/&gt; &lt;method name="&amp;lt;static initializer&amp;gt;"&gt; &lt;coverage type="method, %" value="0% (0/1)"/&gt; &lt;coverage type="block, %" value="0% (0/24)"/&gt; &lt;coverage type="line, %" value="0% (0/3)"/&gt; &lt;/method&gt; &lt;method name="CalculatorData$Message (String, int): void"&gt; &lt;coverage type="method, %" value="0% (0/1)"/&gt; &lt;coverage type="block, %" value="0% (0/5)"/&gt; &lt;coverage type="line, %" value="0% (0/1)"/&gt; &lt;/method&gt; &lt;method name="CalculatorData$Message (String, int, CalculatorData$1): void"&gt; &lt;coverage type="method, %" value="0% (0/1)"/&gt; &lt;coverage type="block, %" value="0% (0/5)"/&gt; &lt;coverage type="line, %" value="0% (0/1)"/&gt; &lt;/method&gt; &lt;method name="valueOf (String): CalculatorData$Message"&gt; &lt;coverage type="method, %" value="0% (0/1)"/&gt; &lt;coverage type="block, %" value="0% (0/5)"/&gt; &lt;coverage type="line, %" value="0% (0/1)"/&gt; &lt;/method&gt; &lt;method name="values (): CalculatorData$Message []"&gt; &lt;coverage type="method, %" value="0% (0/1)"/&gt; &lt;coverage type="block, %" value="0% (0/4)"/&gt; &lt;coverage type="line, %" value="0% (0/1)"/&gt; &lt;/method&gt; &lt;/class&gt; </code></pre> <p>We don't have internal class named Message inside CalculatorData at all. It looks the same as the internal class coverage data so i can't filter them with emma filter. Does anyone know how to get rid of these data in the coverage report?</p> <p>Here is my related ant script. </p> <pre><code>&lt;property name="emma.filter" value="-com.example.coverage.R, -com.example.coverage.R$*, -com.example.coverage.BuildConfig" /&gt; &lt;property name="emma.default.filter" value="com.example.coverage.R, com.example.coverage.R$*, com.example.coverage.BuildConfig" /&gt; &lt;import file="${sdk.dir}/tools/ant/build.xml" /&gt; &lt;!-- use com.zutubi.android.junitreport.JUnitReportTestRunner for getting junit report --&gt; &lt;property name="test.runner.with.report" value="com.zutubi.android.junitreport.JUnitReportTestRunner" /&gt; &lt;!-- refer to run-tests-helper in ${sdk.dir}/tools/ant/build.xml --&gt; &lt;macrodef name="run-tests-helper-with-report"&gt; &lt;attribute name="emma.enabled" default="false" /&gt; &lt;element name="extra-instrument-args" optional="yes" /&gt; &lt;sequential&gt; &lt;echo&gt;Running tests ...&lt;/echo&gt; &lt;exec executable="${adb}" failonerror="true"&gt; &lt;arg line="${adb.device.arg}" /&gt; &lt;arg value="shell" /&gt; &lt;arg value="am" /&gt; &lt;arg value="instrument" /&gt; &lt;arg value="-w" /&gt; &lt;arg value="-e" /&gt; &lt;arg value="coverage" /&gt; &lt;arg value="@{emma.enabled}" /&gt; &lt;extra-instrument-args /&gt; &lt;arg value="${manifest.package}/${test.runner.with.report}" /&gt; &lt;/exec&gt; &lt;/sequential&gt; &lt;/macrodef&gt; &lt;!-- customize system test target using run-tests-helper-with-report for getting junit report --&gt; &lt;target name="test-with-report" depends="-test-project-check" description="Runs tests from the package defined in test.package property"&gt; &lt;property name="tested.project.absolute.dir" location="${tested.project.dir}" /&gt; &lt;!-- Application package of the tested project extracted from its manifest file --&gt; &lt;xpath input="${tested.project.absolute.dir}/AndroidManifest.xml" expression="/manifest/@package" output="tested.manifest.package" /&gt; &lt;xpath input="AndroidManifest.xml" expression="/manifest/@package" output="manifest.package" /&gt; &lt;property name="emma.dump.file" value="/data/data/${tested.manifest.package}/coverage.ec" /&gt; &lt;property name="reports.dir" value="${out.dir}/reports" /&gt; &lt;property name="files.dir" value="/data/data/${manifest.package}/files" /&gt; &lt;echo&gt;Cleaning up previous test reports...&lt;/echo&gt; &lt;delete dir="${reports.dir}" /&gt; &lt;delete dir="${basedir}/coverage" /&gt; &lt;if condition="${emma.enabled}"&gt; &lt;then&gt; &lt;echo&gt;WARNING: Code Coverage is currently only supported on the emulator and rooted devices.&lt;/echo&gt; &lt;run-tests-helper-with-report emma.enabled="true"&gt; &lt;extra-instrument-args&gt; &lt;arg value="-e" /&gt; &lt;arg value="coverageFile" /&gt; &lt;arg value="${emma.dump.file}" /&gt; &lt;/extra-instrument-args&gt; &lt;/run-tests-helper-with-report&gt; &lt;echo&gt;Downloading coverage file into project directory...&lt;/echo&gt; &lt;exec executable="${adb}" failonerror="true"&gt; &lt;arg line="${adb.device.arg}" /&gt; &lt;arg value="pull" /&gt; &lt;arg value="${emma.dump.file}" /&gt; &lt;arg value="coverage.ec" /&gt; &lt;/exec&gt; &lt;echo&gt;Extracting coverage report...&lt;/echo&gt; &lt;emma&gt; &lt;report sourcepath="${tested.project.absolute.dir}/${source.dir}" verbosity="${verbosity}"&gt; &lt;!-- TODO: report.dir or something like should be introduced if necessary --&gt; &lt;infileset dir="."&gt; &lt;include name="coverage.ec" /&gt; &lt;include name="coverage.em" /&gt; &lt;/infileset&gt; &lt;!-- TODO: reports in other, indicated by user formats --&gt; &lt;html outfile="ui-test-coverage.html" encoding="UTF-8"/&gt; &lt;xml outfile="ui-test-coverage.xml" encoding="UTF-8"/&gt; &lt;/report&gt; &lt;/emma&gt; &lt;echo&gt;Saving the report file in ${basedir}/coverage/coverage.html&lt;/echo&gt; &lt;/then&gt; &lt;else&gt; &lt;run-tests-helper-with-report /&gt; &lt;/else&gt; &lt;/if&gt; &lt;echo&gt;Downloading XML test report...&lt;/echo&gt; &lt;mkdir dir="${reports.dir}" /&gt; &lt;exec executable="${adb}" failonerror="true"&gt; &lt;arg line="${adb.device.arg}" /&gt; &lt;arg value="pull" /&gt; &lt;arg value="/data/data/${tested.manifest.package}/files/junit-report.xml" /&gt; &lt;arg value="${reports.dir}/ui-test-report.xml" /&gt; &lt;/exec&gt; &lt;/target&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload