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

AssertionFailedWithCauseError when executing instrumentation tests on Travis CI

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

./gradlew testDebug connectedCheck --stacktrace -PdisablePreDex

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

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.

构建日志中的第 1500 & 1501 as well as 1562 & 1563 行解释了错误所在。这是一个片段:

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

Got: text=As of May 1, 2014 only vehicles with a green sticker are allowed to drive into the low emission zone.

预期字符串以“Since”开头,但实际字符串以“As of”开头

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