title: Generating tests for all-pairs testing
body: <p>I have a short (Java) method with several parameters that performs some non-intuitive computation. Writing unit tests for this method in order to achieve code coverage is trivial, but the tests don't cover the subtleties of the method. I am looking for a testing framework or some other tool that will allow me to do all-pairs (all-tuples) testing for this method, based on partitions that I define for the parameters.</p>
  
  <p>For example, suppose I have the following method:</p>
  
  <pre><code>int foo(int begin, int end, int first, int last) {
      ...
  }
  </code></pre>
  
  <p>I already know some constraints, which may be enforced externally:</p>
  
  <pre><code>begin &lt;= end
  first &lt;= last
  </code></pre>
  
  <p>I want to define explicit equivalence relations, based on my own knowledge of the parameters. For example:</p>
  
  <pre><code>begin == MIN
  begin &gt; MIN &amp;&amp; begin &lt; 0
  begin == 0
  begin == 1
  begin &gt; 1 &amp;&amp; begin &lt; MAX
  begin == MAX
  </code></pre>
  
  <p>I would also like to define equivalence relations involving more than one parameter. For example:</p>
  
  <pre><code>begin + 1 &lt; end
  begin + 1 == end
  begin == end
  </code></pre>
  
  <p>A combination to test is the selection of an equivalence class from each of the equivalence relations (e.g., <code>begin == 0</code> from the first relation and <code>begin + 1 &lt; end</code> from the second relation), such that the constraints are satisfiable. [Incidentally, I realize satisfiability is NP-complete. I'm willing to live with it, given combinations that comprise a relatively small set of constraints.] With several parameters, the number of combinations becomes unwieldy. Manually writing a test for each combination and finding arguments that satisfy the resultant set of constraints is tedious and error prone.</p>
  
  <p>I'm looking for a testing framework that can automatically test each combination, or a test generator that can generate a test for each logically consistent combination (invariant checks to be inserted by yours truly). This is different from test-generation tools like <a href="https://developers.google.com/java-dev-tools/codepro/doc/features/junit/test_case_generation" rel="nofollow">CodePro</a>, which generate test cases from the actual implementation. Effectively, I want to generate tests for an interface of the method, rather than its implementation. Not only would this allow me to write the tests before the method is implemented (TDD), but it would ensure the method is comprehensively tested even after its later modification.</p>
  
  <p>Does such a tool exist, or can something be kludged together? Or perhaps I'm approaching this the wrong way, and you have another suggestion...</p>