在Travis CI上执行检测测试时出现AssertionFailedWithCauseError

问题描述 投票:0回答:1

我在我的Espresso上运行基于Android project 2.2.2的仪器测试。当我通过以下命令在本地针对不同设备(例如Nexus 5手机(Android 6.0.1)和Nexus 9平板电脑(Android 7.1.1))运行它们时,所有测试都成功:

./gradlew testDebug connectedCheck --stacktrace -PdisablePreDex

一旦我用这个configuration在Travis CI上运行相同的任务,那么其中两个测试失败并出现一个令人困惑的错误消息:

CityInfoFragmentTest > renderCityInfoWithStandardZone[test(AVD) - 4.3.1] FAILED 
    android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 

    'with text: is 
    "Since May 1, 2014 only vehicles with a green sticker are allowed to drive into the low emission zone."
    ' doesn't match the selected view.

    Expected: with text: is 
    "Since May 1, 2014 only vehicles with a green sticker are allowed to drive into the low emission zone."

如您所见,实际和预期的文本匹配!?!


我没有使用Espresso 3.0.2,因为有一个bug which prevents running tests on certain devices

android travis-ci android-espresso android-testing
1个回答
1
投票

构建日志中的1500 & 1501行和1562 & 1563解释了出了什么问题。这是一个片段:

预计:带文字:“自2014年5月1日起,只有带绿色标签的车辆才能驶入低排放区。”

得到:text =截至2014年5月1日,只允许带有绿色标签的车辆驶入低排放区。

期望的字符串以“Since”开头,但实际的字符串以“As”开头

您是否在测试中对字符串进行了硬编码?如果是这样,你不应该:)

© www.soinside.com 2019 - 2024. All rights reserved.