expected: but was:

  今天写程序,突然看到这个错误:junit.framework.AssertionFailedError: expected: but was:
把错误发到群里,震惊了世界后,突然发现了原因。
  assertEquals(resume.getSex(), “男”);
应该是
  assertEquals(resume.getSex().toString(), “男”);
  少了个toString()。但是我自己为了前台输出方便,在Sex类里实现了toString。结果junit在输出错误的时候就输出了那个”男”,然后就有了那个神奇的错误信息。

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s