## Symmetric Test Case Input

I ran across an interesting testing situation the other day. I was looking at a library module for 7-card poker which contains a method int Hand.Compare(Hand h1, Hand h2) to determine which of two 7-card poker hands is better according to the rules of poker. This is a surprisingly tricky method to code up and I use it for many different types of software testing investigations. Anyway, consider these two poker hands:

h1 = Ac Ad Ah 9s 9c 9d 2c
h2 = Kc Kd Ks Jc Jd Js Qh

The first hand is a full house Aces over Nines (usually pronounced Aces full of Nines). The second hand is a full house Kings over Jacks. A call to Hand.Compare(h1, h2) should return -1 because h1 is better than h2. OK, but if you execute this test case should you also execute Hand.Compare(h2, h1) with an expected result of +1? The answer is yes, absolutely. Well this is basically testing 101 information but it got me to thinking about situations where you absolutely need to create symmetric test case input. I didn’t come up with any remarkable epiphanies but it did remind me that there are a few testing principles, like you should almost always create test cases with symmetric input, that are easy to overlook.