Skip to content

Prettify the error message of TestObserver #6352

Closed

Description

@jaychang0917

Version: 2.2.5

It may be better if the Expected message and Actual one are printed on its OWN line instead of contacting them. It's a hard time to find out what the difference is.

java.lang.AssertionError: Values at position 0 differ; Expected: MobileNumberState(isErrorMsgVisible=false, isNextButtonVisible=false, isNextButtonEnabled=false, selectedCountry=Country(name=China, code=86), mobileNumber=, navigation=null) (class: MobileNumberState), Actual: MobileNumberState(isErrorMsgVisible=false, isNextButtonVisible=false, isNextButtonEnabled=false, selectedCountry=Country(name=HK, code=852), mobileNumber=, navigation=null) (class: MobileNumberState) (latch = 1, values = 1, errors = 0, completions = 0)

What I expect is

java.lang.AssertionError: Values at position 0 differ;
Expected: MobileNumberState(isErrorMsgVisible=false....
Actual:   MobileNumberState(isErrorMsgVisible=false....

Activity

  1. akarnokd commented on Dec 31, 2018

    @akarnokd
    Member

    I don't know how IntelliJ Idea handles multiline exceptions with its diff viewer. If you are not on IntelliJ, I recommend using Notepad++ or alike to disect such long messages. Or you could always have your own test comparisons that print your objects formatted.

  2. jaychang0917 commented on Dec 31, 2018

    @jaychang0917
    Author

    I'm using IntelliJ, the above error message is shown on the console when my test case failed. It seems doesn't relate to diff viewer.

  3. jaychang0917 commented on Dec 31, 2018

    @jaychang0917
    Author

    The source code of BaseTestConsumer.assertValues():

    //...
    throw fail("Values at position " + i + " differ; Expected: " + valueAndClass(u) + ", Actual: " + valueAndClass(v));

    Changing the format of that string with newline operator will solve the long message issue, doesn't it? Am I missing something?

  4. akarnokd commented on Dec 31, 2018

    @akarnokd
    Member

    See #6262. Also you could include a newline in your toString representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions