Issue
I am running instrumentation tests based on Espresso 2.2.2 in my Android project. All tests succeed when I run them locally against different devices such as a Nexus 5 phone (Android 6.0.1) and a Nexus 9 tablet (Android 7.1.1) via the following command:
./gradlew testDebug connectedCheck --stacktrace -PdisablePreDex
Once I run the same task on Travis CI with this configuration then two of the tests fail with a confusing error message:
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."
As you can see the actual and expected texts do match!?!
I am not using Espresso 3.0.2 because there is a bug which prevents running tests on certain devices.
Solution
Lines 1500 & 1501 as well as 1562 & 1563 in the build log explain what went wrong. Here's a snippet:
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.
The expected string begins with "Since" but the actual string begins with "As of"
Are you hardcoding strings in your test? If so, you shouldn't :)
Answered By - A Droid
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.