oss

XBRLAPI Unit testing with JUnit

Overview

A comprehensive test of your XBRLAPI installation is possible using the JUnit 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 conformance suite is available as a zip file from the XBRL.ORG 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).

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.

Among other possibilities, you can set this system property by adding -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 the /path/to/configuration/file to a the value of 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 a complete properties file from the SVN repository.

Execute the Unit Tests

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

Unit testing from the command line

You can use one of the TestRunner classes provided by JUnit to do the unit tests from the command line. For example, to use the text UI test runner, for the full set of tests except those for persistent data stores, you could use (presuming all the necessary classes are on the classpath):

java -Xmx1g -Dxbrlapi.test.configuration=[PATH.TO.CONFIGURATION.FILE] junit.textui.TestRunner org.xbrlapi.tests.AllTests

You would have to replace [PATH.TO.CONFIGURATION.FILE] with the full path to and the file name of the file containing the test configuration properties.

The -Xmx1g parameter is supplied to ensure that you do not run into memory limitations when running some of the more demanding unit tests.

SourceForge Logo