square / assertj-android

A set of AssertJ helpers geared toward testing Android.
https://square.github.io/assertj-android/
Apache License 2.0
1.58k stars 156 forks source link

honor .as() method on asserts #84

Open yogurtearl opened 11 years ago

yogurtearl commented 11 years ago

Update various asserts to honor descriptions passed to "as".

E.g.

assertThat(fooView).as("Foo").isGone()

would print:

Expected Foo to be gone but was visible

For example isGone would contain would be roughly ( based on your current code ):

assertThat(actualVisibility) 
        .overridingErrorMessage("Expected " +
        getWritableAssertionInfo().getDescriptionText() 
             + " to be gone but was %s",
            visibilityToString(actualVisibility)) 
        .isEqualTo(GONE);

Reference:

https://github.com/alexruiz/fest-assert-2.x/blob/fest-assert-core-2.0M10/src/main/java/org/fest/assertions/api/AbstractAssert.java

https://github.com/alexruiz/fest-assert-2.x/blob/fest-assert-core-2.0M10/src/main/java/org/fest/assertions/core/WritableAssertionInfo.java

JakeWharton commented 10 years ago

:thumbsup: Going to be a lot of manual work... we have a lot of assertions!