Junit4 Android TestField text test -


my test is:

@runwith(androidjunit4.class) @largetest public class tipactivitytests {      @rule     public activitytestrule<tipactivity> mactivityrule = new activitytestrule<>(tipactivity.class);      @test     public void initialvalues() {         onview(withid(r.id.tip_label_base_price)).check(matches(viewmatchers.withtext("45"")));     }  } 

but error 'with text: "45"' doesn't match selected view. expected: text: "45":

android.support.test.espresso.base.defaultfailurehandler$assertionfailedwithcauseerror: 'with text: "45"' doesn't match selected view. expected: text: "45" got: "appcompattextview{id=2131689669, res-name=tip_label_base_price, visibility=visible, width=266, height=106, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=141.0, y=96.0, text=$ 45.00, input-type=0, ime-target=false, has-links=false}" 

it dosen´t make sense me, should not print actual value of field vs compared value?

i had same problem , spent quite time trying understand root cause. turned out strings not equals, that's why failing. error message not explicit because it's printing whole object properties etc instead of saying: expected: "foo", received: "bar". strings compared.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -