title: Testing large input range scenarios with JUnit
body: <p>I am pondering on how it is best to develop a JUnit test for a function that calculates a number of points and values in time based on a number of inputs.  The purpose of the method is to calculate a series of points in time given a series of gradient value pairs, i.e.</p>
  
  <p>Gradient 1 to Value 1, Gradient 2 to Value 2, Gradient 3 to Value 3, and so on...</p>
  
  <p>Given a starting point in time and starting value, the function calculates the points in time each Value is reached (in the gradient value pairs) up until a target value is reached.  This is essentially to plot a line on a graph with x-axis having date values and the y-axing having numeric values.</p>
  
  <p>The method to test takes the following inputs:</p>
  
  <ul>
  <li>StartTime (Date)</li>
  <li>StartValue (Double)</li>
  <li>TargetValue (Double)</li>
  <li>GradientValuePairs (ArrayList)</li>
  <li>EnsurePointEvery5Minutes (Boolean)</li>
  </ul>
  
  <p>Where GradientValuePair is like:</p>
  
  <pre><code>class GradientValuePair {
      Double gradient; // Gradient up to Target
      Double target;
      ...
  }
  </code></pre>
  
  <p>The output from this method is essentially ArrayList - a profile - with:</p>
  
  <pre><code>class DatePoint {
      Date date;
      Double value;
      ...
  }
  </code></pre>
  
  <p>The EnsurePointEvery5Minuntes parameter basically adds a date point every 5 minutes for the calcualted profile which is then returned by the method.</p>
  
  <p>To ensure the test has worked I will need to check each date and value is to what is expected by either:</p>
  
  <ul>
  <li>Iterating through the array with an array of what is expected.</li>
  <li>Store minute/second offsets from the StartTime with the expected value in some sort of structure.</li>
  </ul>
  
  <p>Now the difficult part for me is deciding on how to write the TestCase.  I want to test a broad/diverse range of inputs so that:</p>
  
  <ul>
  <li><strong>StartTime</strong> will cover 30 minutes i.e. in range of 2012-03-08 00:00 to 2012-03-08 00:30.</li>
  <li><strong>StartValue</strong> will be in the range of 0 to 1000.</li>
  <li><strong>TargetValue</strong> will be in the range of StartValue to 1000.</li>
  <li><strong>GradientValuePairs</strong> will require around 10 different arrays to be tested.</li>
  <li><strong>EnsurePointEvery5Minutes</strong> will be tested with both true and false.</li>
  </ul>
  
  <p>Now given the number of different input sets will be something like:</p>
  
  <p>30 * (0 to 1000 * 0 to 1000 = 500500) * 10 * 2 = <strong>300,300,000 different test input sets per GradientValuePairs input</strong></p>
  
  <p>Or call us crazy for wanting to do this.  Maybe the tests are too diverse for this instance.  </p>
  
  <p>I am wondering if anybody has any advice for testing such scenarios like this.  I can't think of any other way to do this than implement my own algorithm for calculating the output before each call to the method I am testing - then who is to say that the algorithm I implement to test it is correct.</p>