Free Open-Source Software

XBRLAPI Unit testing with TestNG

Overview

XBRLAPI uses TestNG for unit testing.

A comprehensive test of your XBRLAPI installation is possible using the TestNG tests that are distributed with XBRLAPI.

Install a local version of the XBRL 2.1 conformance suite

If you want to run the unit tests that are distributed with XBRLAPI, then it is necessary to configure the test data environment. A key part of this configuration involves installation of the XBRL 2.1 conformance suite.

The XBRL 2.1 conformance suite is available from the XBRL website.

Download the zip file and extract it to the desired location in your local environment. You can either serve up the files in the conformance suite directly from your local file system (using the file scheme URLs) or you can serve them via a local web server such as Apache (using http scheme URLs).

Install a local version of the XBRL Dimensions conformance suite

The XBRL Dimensions conformance suite is available from the XBRL website.

Set up the test configuration file

It is necessary to set a range of test configuration properties to provide information regarding the setup of the underlying data stores and the available test data. This is done using a Java properties file whose location must be specified by a system property called xbrlapi.test.configuration.

The test configuration file sets a large number of configuration properties. These are explained in the test configuration documentation.

One way to specify the location of the properties file is to add -Dxbrlapi.test.configuration=/path/to/configuration/file/filename to the set of parameters used when running Java. In Eclipse, add this as a virtual machine argument for your project's java runtime environment. Naturally set /path/to/configuration/file to the path to the configuration file that you want to use and set filename to the name of your configuration file.

You can grab a copy of an up-to-date properties file from the GIT repository. Note that it will need to be customised to reflect your own directory structures.

Execute the Unit Tests

Unit test execution can be done in a number of ways. These include:

Unit testing from within Eclipse

Install the TestNG Eclipse plugin.

Select the set of test classes or methods that you want to execute, and then run them from the context menu in Eclipse.

Unit testing using Maven

From the directory containing the POM file for the module that you want to test, run, at the command line:

mvn test

Get Java XBRL API implementation at SourceForge.net. Fast, secure and Free Open Source software downloads