Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • I believe tallseth's motivation for randomizing the values is to test multiple valid and invalid combinations. After a while you have tested [1,1,2,2,2], [1,2,2,2,1], [1,1,3,3,3], [1,1,4,4,4], ..., [5,5,5,6,6]. Commented Feb 7, 2013 at 9:06
  • 1
    @Kristof Claes: yes, and Telastyn's criticism is fully valid: what do you do if suddenly one test fails, and when you run it again, it's successful? Commented Feb 7, 2013 at 9:23
  • 2
    @MichaelBorgwardt : Maybe you can pass the roll-value to the Assert? Like Assert.IsTrue(sut.IsFullHouse(roll), roll.ToString()); with NUnit. This way you know what values caused the test to fail. Commented Feb 7, 2013 at 10:25
  • Certainly. One might also implement AnyFullhouse by having 3 hardcoded FullHouse values, and picking one at random. The worst case scenario is some random value hits a test case you haven't thought of, and the test failure is a valid one. The nunit RepeatAttribute has always allowed me to find such failures very quickly. Commented Feb 8, 2013 at 14:25
  • 1
    +1 for "people make excuses as to why they fail" though. I haven't experienced that, but I also didn't think about this problem on the team-psychology dimension. Commented Feb 8, 2013 at 14:27