Codename One - tests.dat file needed when using build.unitTest=1

自古美人都是妖i 提交于 2019-12-08 03:49:22

问题


I created a test extending the AbstractTest class. The test works correctly in Netbeans: I right-click on the project name, then on "Test". Of course the Netbeans test in done in the Codename One Simulator. I want to repeat the test on several real devices, as I asked in "Codename One - Test Recorder: execute a test on a real device"

So I added the build.unitTest=1 build hint and I checked that my build.xml contains:

<target name="test-for-ios-device" depends="clean,copy-ios-override,copy-libs,compile-test,clean-override">
    <codeNameOne 
        jarFile="${dist.jar}"
        displayName="${codename1.displayName}"
        packageName = "${codename1.packageName}"
        mainClassName = "${codename1.mainName}"
        version="${codename1.version}"
        icon="${codename1.icon}"
        vendor="${codename1.vendor}"
        subtitle="${codename1.secondaryTitle}"
        buildArgs="build.unitTest=1"
        targetType="iphone"
        certificate="${codename1.ios.debug.certificate}"
        certPassword="${codename1.ios.debug.certificatePassword}"
        provisioningProfile="${codename1.ios.debug.provision}"
        appid="${codename1.ios.appid}"
        automated="${automated}"
        />
</target>

<target name="test-for-android-device" depends="clean,copy-android-override,copy-libs,compile-test,clean-override">
    <codeNameOne 
        jarFile="${dist.jar}"
        displayName="${codename1.displayName}"
        packageName = "${codename1.packageName}"
        mainClassName = "${codename1.mainName}"
        version="${codename1.version}"
        icon="${codename1.icon}"
        vendor="${codename1.vendor}"
        subtitle="${codename1.secondaryTitle}"
        buildArgs="build.unitTest=1"
        targetType="android"
        keystoreAlias="${codename1.android.keystoreAlias}"
        keystore="${codename1.android.keystore}"
        certPassword="${codename1.android.keystorePassword}"
        automated="${automated}"
        />
</target>

After that, I sent an iOS build: it doesn't compile. So I tried to send an Android build. The generated apk, on a real device, produces an error because the /tests.dat file is absent. The exact error is: "Test data not found in the file, make sure the ant task was executed in full" (it's produced by DeviceRunner class at line 57). I added an empty tests.dat in /src, but it's not useful, because no test is runned.

I don't know what I have to do.

I need step-by-step instructions to test an app on a real device in the same way that I do in the Codename One Simulator. Thanks.


回答1:


In the compile-test target which is the base target required we have this line:

<prepareTests classesDir="${build.classes.dir}" testClassesDir="${build.test.classes.dir}" seJar="JavaSE.jar" metaDataFile="${build.test.classes.dir}/tests.dat" />

This should generate a valid tests.dat file for the test directory which should get packaged into the build.



来源:https://stackoverflow.com/questions/47705452/codename-one-tests-dat-file-needed-when-using-build-unittest-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!