FeaturesPluginsDocs & SupportCommunityPartners

XTest for Java Projects

Author: Jiri Skrivanek
Last update: January 30, 2006



This document should briefly introduce XTest testing infrastructure in NetBeans for Java projects. You can watch a demo to get a basic insight.

Introduction

Every test type in sense of XTest has its own packages node. It is common to have at least unit tests and functional tests. Unit tests check correctness of written code an method base. They are usually run against binaries without a need to start IDE. On the other hand functional tests check functionality of resulting application as a whole. They are usually UI tests which run on started IDE.

Inspect sample project

You can inspire how to set testing infrastructure for your Java project in XTest Sample module. This module is available on Update Center and it is dependent on module XTest Module and Jemmy Module. From Tools menu call Update Center item and in the wizard choose modules Jemmy Module, XTest Module and XTest Sample. Then after successful installation there will be available sample project. Open New Project wizard and select Anagram Game With XTest in Samples|Testing Tools category. Create project and look at test packages in Projects view and also test scripts in Files view

Build & Run Tests in IDE

Actions to compile and run tests in IDE are in context menu on project node when XTest Module is installed:
  • XTest
    • Clean  - clean tests and results. In fact it calls targets realclean from test/build.xml.
    • Build ${xtest.testtype} Tests - build tests using XTest build scripts. In fact it calls target buildtests from test/build.xml with parameter -Dxtest.testtype.
    • Run ${xtest.testtype} Tests -  run tests using XTest build scripts and show results in default browser. In fact it calls target runtests from test/build.xml with parameter -Dxtest.testtype.
${xtest.testtype} is replaced  by test type name (e.g. unit, qa-functional). It means every test type has a pair of build and run actions. Property xtest.home is set to ${netbeans.user}/xtest-distribution

Build & Run Tests from Command Line

Property netbeans.dest.dir points to NetBeans installation directory which is by default nbbuild/netbeans. Command then could look like this:

cd mymodule/test
ant -Dnetbeans.dest.dir=D:/builds/041027/netbeans -Dxtest.testtype=qa-function
al -Dxtest.attribs=validation

If you omit all parameters, there will be used default ones as defined in test/build.xml. Target runtests is called by default. You can run additional targets like buildtests, cleantests, cleanresults, realclean.



Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by