Package com.onenetwork.platform.tools.test
Classes for implementing automated unit and functional test cases (both inside and outside the container).
Within a Platform Module, automated tests fall into one of the following categories:
1. Unit Tests
Unit tests are simple, standalone JUnit testcases which do not require server resources such as database connections, EJB transaction management, etc. For example, you may have a function which calculates a result given certain inputs, and you want to write a test case which exercises several different inputs and validates the results. To implement a unit test, your testcase should be in thetest-src
directory
of your Module, it should extend AbstractUnitTest
, and it should use the naming convention *UnitTest
,
for example CalculationUnitTest
.
2. Server Tests
Server tests are tests which must be executed from within a running server as they require servics such as database connections, EJB transaction management, etc. For example, you may have a class which creates Users in the database in response, and you want to make sure the Users are actually persisted properly. To implement a server test, your testcase should be in thetest-src
directory
of your Module, it should extend AbstractServerTest
, and it should use the naming convention *ServerTest
,
for example UserCreationServerTest
.
3. UI Tests
UI tests are tests which interact with the UI, so they are similar to server tests in that they need the server to be running when executed. They are written to automate and test interactions with the UI, such as entering data with the keyboard and clicking with the mouse. To implement a UI test, your testcase should be in thetest-src
directory of your Module, should follow standard JUnit 3 or 4 unit test guidelines,
and should use the naming convention *UITest
(i.e. ModelCRUDUITest
).-
Interface Summary Interface Description Condition.Supplier<T> Function used to compute a value in a Condition.Condition.Test<T> Function used to validate a value in a Condition. -
Class Summary Class Description AbstractGroovyServerTest Base class for server-tests written in Groovy.AbstractServerTest Tests which run within the container should extend AbstractServerTest and use the naming convention *ServerTest.AbstractUnitTest Tests which run outside the container should extend AbstractUnitTest and use the naming convention *UnitTest.Condition<T> Utility allowing one to "await" a certain "condition" to occur.Matchers Hookpoint class enabling use of org.hamcrest Matchers in test framework.
Example usage: -
Annotation Types Summary Annotation Type Description Tags Can be used to annotate tests with additional "tags" for analytic purposes.TransactionalServerTest Annotate a ServerTest class with this and each test method will run in a transaction which is automatically rolled back at the end of the test.