All the UISpec4J component wrappers provide methods for checking the underlying component state. These methods return Assertion objects responsible for performing the check. They are meant to be used with the UISpecAssert.assertTrue() method, which is also available as an instance method in UISpecTestCase .
For instance, when checking the text displayed on a button, you will write:
assertTrue(button.textEquals("OK"));
In order to check the contents of a tree, you will write:
assertTrue(tree.contentEquals("root\n" + " element1\n" + " element2"));
The UISpecAssert.assertTrue() method retries checking the assertion when the first check fails, in order to abstract the tests from the fact that sometimes the user interface needs a little delay before being refreshed, especially in multi-threaded applications. This delay is set with UISpec4J.setAssertionTimeLimit() .
The default retry delay is meant to be used for most actions. In cases where your application provides some actions that take longer than average, you can use the UISpecAssert.waitUntil() or UISpecTestCase.waitUntil() methods:
waitUntil(button.isEnabled(), 10000);
The UISpecAssert class provides a number of boolean operators for managing assertions: not, or, and.
These methods are also implemented in UISpecTestCase, so that you don't have to use the UISpec4J prefix in your tests. You can then write something like:
assertTrue(and(button.isEnabled(true), button.textEquals("OK")));