Java/ JUnit - AssertTrue vs AssertFalse

后端 未结 7 829
旧巷少年郎
旧巷少年郎 2020-12-23 09:28

I\'m pretty new to Java and am following the Eclipse Total Beginner\'s Tutorials. They are all very helpful, but in Lesson 12, he uses assertTrue for one test c

7条回答
  •  盖世英雄少女心
    2020-12-23 10:06

    assertTrue will fail if the checked value is false, and assertFalse will do the opposite: fail if the checked value is true.

    Another thing, your last assertEquals will very likely fail, as it will compare the "Book was already checked out" string with the output of m1.checkOut(b1,p2). It needs a third parameter (the second value to check for equality).

提交回复
热议问题