Time for action – running the test set
Implement your runSelectedTest
method. This method will be called when the user presses the Time it! button:
public void runSelectedTest() { Long times = Long.parseLong(textField.getValue()); Collection<String> results = TestSetExecutor.execute( (TestSet) combo.getValue(), times); showResults(results); }
What just happened?
Here, we're converting the string stored in the text field to a Long
number using Long.parseLong
(a potential exception, NumberFormatException
, pokes its head).
Once we have the Long
value, we execute the results using a helper class in the biz
package (TestSetExecutor
). This helper class has an execute
method that expects the TestSet
to execute and the number of iterations to perform for each test in the TestSet
. The execute
method returns all the results as a collection of strings that we can proudly show to the user. As proudly as Susan when she presented her code.
Have a go hero – add a validation to Time It
When...