Code Structure
The XNAT REST tests rely on two custom libraries:
grxnat: https://bitbucket.org/xnatdev/grxnat . If you're familiar with PyXNAT or xnatpy, this is a similar project where interacting with XNAT over REST is exposed in groovy (rather than python). While grxnat is written in groovy, it's compiled to a Java jar so it can be used within the Java-based REST tests. The mechanism for actually building, issuing, and validating the HTTP calls is done using the REST-assured (https://rest-assured.io/) library. The functionality for interacting with XNAT is all accessible via the
XnatInterface
class. The following library offers several easy ways to grabXnatInterface
objects corresponding to standard test accounts.- nrg_test: https://bitbucket.org/xnatdev/nrg_test . This library is also groovy-based but compiled as a jar. The library extends the functionality of TestNG (https://testng.org/doc/) to provide the testing framework for XNAT. It provides:
- Base test classes to be used for writing XNAT tests
- Annotations for customizing various aspects of XNAT tests (see Test control/specification via annotations)
- Additional code for issuing direct commands to the tested XNAT instance over SSH, or for issuing direct database calls
- Various other reusable shortcuts for bridging the gap between grxnat (which is intended to be more of a general-use XNAT groovy SDK) and desired functionality for testing
The XNAT REST tests themselves (https://bitbucket.org/xnatdev/xnat_rest_tests) are fully Java, so adding/modifying tests requires no knowledge of groovy.