-1

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!!

Jitesh Upadhyay
  • 5,244
  • 2
  • 25
  • 43
  • 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 '17 at 02:58
  • formattedDecimal is a string – Jitesh Upadhyay May 10 '17 at 02: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 '17 at 03:00
  • sure, will check on the same, however space is there as seen. – Jitesh Upadhyay May 10 '17 at 03:02
  • 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 '17 at 03:07
  • Maybe you're inadvertently running an earlier version of your code. Try cleaning out your build directory and recompiling. – Dawood ibn Kareem May 10 '17 at 03:08
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a [mcve]. Beyond that: I would simply write code that compares both strings character by character to see what is going on. – GhostCat May 10 '17 at 06:45

1 Answers1

1

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())
holi-java
  • 29,655
  • 7
  • 72
  • 83