T3 is a powerful automated unit testing tool to test Java classes. Given a target class to test, it randomly generates sequences of calls to the class' methods to test it. It catches unexpected exception; but if you had written assertions in the class, then violations to those will be caught as well. T3 is the successor of T2. The main idea is still the same as T2, however the engine has been completely revamped. Internally, T3 makes a lot of use of Java 8's closures, to make its generators infrastructure more customizable
Here is a simple class implementing a sorted list of integers. The list is sorted in ascending order. It has a method to insert an element, and a method to retrieve the greatest element from the list.
package Examples; import java.util.LinkedList; // Sorted list of integers; in ascending order. public class SimpleIntSortedList { private LinkedList s; private Integer max; public SimpleIntSortedList() { s = new LinkedList(); } public void insert(Integer x) { assert x!=null : "PRE"; int i = 0; for (Integer y : s) { if (y > x) break; i++; } s.add(i, x); // bug: should be x > max if (max == null || x < max) max = x; } // Retrieve the greatest element from the list, if it is not empty. public Integer get() { assert !s.isEmpty() : "PRE"; Integer x = max; s.remove(max); if (s.isEmpty()) max = null ; else max = s.getLast() ; assert s.isEmpty() || x >= s.getLast() : "POST"; return x; } // a class invariant private boolean classinv__() { return s.isEmpty() || s.contains(max); } }
View MANUFACTURERS Wallboard
Theme by Danetsoft and Danang Probo Sayekti