相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

While having the unit test case writing for French and Czech localization, on doing

  assertThat(formattedDecimal).isEqualTo("8 771,23");

where formattedDecimal is a string , had a result

org.junit.ComparisonFailure: 
Expected :"8 771,23"
Actual   :"8 771,23"

why it failed? did not understand, please guide what i am doing wrong here!!

Is formattedDecimal a String, or some other type? It would need to be a String for this assertion to pass, since you're comparing it to a String. – Dawood ibn Kareem May 10, 2017 at 2:58 OK, use a debugger to inspect the value of formattedDecimal to make sure there aren't any unexpected characters in there, for example, a non-breaking space instead of an ordinary space. – Dawood ibn Kareem May 10, 2017 at 3:00 After debugging did not seen the difference by visuals but interestingly when copied Actual to do isEqualTo, it worked. Really confused – Jitesh Upadhyay May 10, 2017 at 3:07

maybe your formattedDecimal including some control letters that can't see in the console. have you tried this?

assertThat("foo\bo").isNotEqualTo("foo");// ok
          //   ^--- it print "foo"             
assertThat(formattedDecimal.getBytes()).isEqualTo("8 771,23".getBytes())
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

 
推荐文章