Log In | Sign Up   View a printable version of the current page.
  Dashboard > [fleXive] > ... > Checking out and working with the sources > Running Unit Tests

Added by Markus Plesser, last edited by Markus Plesser on Apr 15, 2010  (view change)
Labels: 
(None)

Running Unit Tests

[fleXive] (version 3.1+) comes with a bundled OpenEJB container to be able to run unit tests.

To run H2 unit tests follow these instructions (for MySQL just change the sections accordingly):

  1. Check out the sources as described in Checking out.
  2. In the root directory, copy build.properties.sample to build.properties
  3. If you want to use the bundled H2 database, comment out the last line in build.properties and enable the H2 database. The end of the file should look like this:
    ...
    #select the database vendor to use
    database.vendor=H2
    #database.vendor=MySQL
  4. Copy lib/openejb-3.1/openejb-tests.conf.xml.sample to lib/openejb-3.1/openejb-tests-H2.conf.xml
  5. Comment out the MySQL configuration in lib/openejb-3.1/openejb-tests-H2.conf.xml and enable the H2 config to create a file similar to this:
    <?xml version="1.0"?>
    <openejb>
        <!-- H2 settings -->
        <Resource id="jdbc/flexiveConfiguration" type="DataSource">
            JdbcDriver org.h2.Driver
            JdbcUrl jdbc:h2:tcp://localhost:9092/~/flexiveConfiguration;SCHEMA=flexiveConfiguration;LOCK_TIMEOUT=10000;MVCC=TRUE;TRACE_LEVEL_FILE=0
            UserName sa
            Password
        </Resource>
        <Resource id="jdbc/flexiveTest" type="DataSource">
            JdbcDriver org.h2.Driver
            JdbcUrl jdbc:h2:tcp://localhost:9092/~/flexiveTest;SCHEMA=flexiveTest;LOCK_TIMEOUT=10000;MVCC=TRUE;TRACE_LEVEL_FILE=0
            UserName sa
            Password
        </Resource>
        <SecurityService id="Default Security Service"/>
        <Deployments jar="../../build/framework/jar/flexive-ejb.jar"/>
        <!--TransactionService id="Default Transaction Manager"/-->
    </openejb>
  6. Start the H2 database by executing
    ant h2.start
    Please run ant h2.start and do not start H2 manually, since launching from the build file will make sure the needed stored procedures are available!

To finally run the tests either execute

ant tests.all
for all tests or specify the groups to run (search in this example):

ant tests.groups -Dtests.groups=search

For other available targets please see the section Build Targets.

Running Unit Tests in the [fleXive] Backend Application

In order to run the unit tests within the [fleXive] BE the "Testrunner" plugin must be compiled and deployed with the flexive.ear package.

Execute the following ant target to have access to the Testrunner plugin:

ant tests.package.ear build-deploy
Make sure to create the flexiveTest database schema before starting up by issuing the ant target
ant db.update.test

After starting up [fleXive] and logging in with superuser credentials you will find a "Testrunner" submenu within the "System" menu (Administration tab):

Site running on a free Atlassian Confluence Open Source Project License granted to [fleXive] . Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.1 Build:#916 Nov 09, 2007) - Bug/feature request - Contact Administrators