简体   繁体   English

使用ant与库项目R18的Android单元测试

[英]Android unit test using ant with library project R18

I am having the same issues as in This question: Android unit test using ant with library project 我遇到了与此问题相同的问题: 使用ant与库项目进行Android单元测试

I tried both methods that was suggested in the question, but on the r18 release of the android tools, I am getting: 我尝试了问题中提出的两种方法,但是在Android工具的r18版本中,我得到了:

NTServicesTest/build.xml:110: Reference jar.libs.ref not found. 

I am not sure if it's me who have failed at following the recipe for the workaround for the answers to the original question, or if something has changed in r18 of the android tools. 我不确定是不是我没有按照原始问题的答案的解决方法的配方,或者如果在Android工具的r18中发生了某些变化。

my folder setup is on proj folder that contains..: 我的文件夹设置在包含..的proj文件夹中:

NTServices , NTServicesTest , NTServicesTestApp NTServices,NTServicesTest,NTServicesTestApp

For the workaround of @Snicolas I modified my NTServicesTest/project.properties to look like this: 对于@Snicolas的解决方法,我修改了我的NTServicesTest / project.properties,如下所示:

# Project target.
target=android-15
tested.android.library.reference.1=../NTServices

And my NTServicesTest/build.xml looks like this : (from right under the version tag ) 我的NTServicesTest / build.xml看起来像这样:(从版本标签的右下方)

 <import file="${sdk.dir}/tools/ant/build.xml" />


    <!-- override "compile" target in platform android_rules.xml to include tested app's external libraries -->
 <!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
<do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
    <!-- If android rules are used for a test project, its classpath should include
         tested project's location -->
    <condition property="extensible.classpath"
            value="${tested.project.absolute.dir}/bin/classes"
            else=".">
        <isset property="tested.project.absolute.dir" />
    </condition>
    <condition property="extensible.libs.classpath"
            value="${tested.project.absolute.dir}/${jar.libs.dir}"
            else="${jar.libs.dir}">
        <isset property="tested.project.absolute.dir" />
    </condition>
    <echo message="jar libs dir : ${tested.project.target.project.libraries.jars}"/>
    <javac encoding="${java.encoding}"
            source="${java.source}" target="${java.target}"
            debug="true" extdirs="" includeantruntime="false"
            destdir="${out.classes.absolute.dir}"
            bootclasspathref="android.target.classpath"
            verbose="${verbose}"
            classpath="${extensible.classpath}"
            classpathref="jar.libs.ref">
        <src path="${source.absolute.dir}" />
        <src path="${gen.absolute.dir}" />
        <classpath>
            <!-- steff: we changed one line here !-->
            <fileset dir="${tested.android.library.reference.1}/bin/" includes="*.jar"/>
            <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
        </classpath>
        <compilerarg line="${java.compilerargs}" />
    </javac>
           <!-- if the project is instrumented, intrument the classes -->
                    <if condition="${build.is.instrumented}">
                        <then>
                            <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
                            <!-- It only instruments class files, not any external libs -->
                            <emma enabled="true">
                                <instr verbosity="${verbosity}"
                                       mode="overwrite"
                                       instrpath="${out.absolute.dir}/classes"
                                       outdir="${out.absolute.dir}/classes">
                                </instr>
                                <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
                                     user defined file -->
                            </emma>
                        </then>
                    </if>           
</do-only-if-manifest-hasCode>
</target>

只需将classpathref =“jar.libs.ref”重命名为classpathref =“project.libraries.jars”。

yes it worked. 是的,它有效。 in R18 this propertyes changet to project.libraries.jars but in owerrided task we did'nt change this value 在R18中,这个属性改变为project.libraries.jars但是在强制任务中我们没有改变这个值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM