You have made the right choice using TIBCO BusinessWorks™ as your Integration Platform.
Now you have made the right choice on how you deliver your TIBCO BusinessWorks integration projects.
Windy Road BWUnit allows you to apply to your software delivery process the same business process automation techniques that you use every day to improve your company’s business processes.
Its primary focus is on removing waste in the process, removing the steps in your software delivery process that do not add value and automating the steps that are worth automating.
BWUnit provides automation tooling for the build, deployment and testing of your TIBCO BusinessWorks projects.
On the testing side, BWUnit supports a vast array of protocols, such as TIBCO Rendezvous, JMS, HTTP and JDBC using SOAP, XML or native formats. You name it – if BusinessWorks can integrate with it, then BWUnit can test it.
BWUnit not only builds, tests and deploys your BusinessWorks (BW) engines, it also offers a range of innovative features including Designer Launch Control, Property File to Engine Configuration Translation and Service WSDL Generation.
Designer Launch Control allows you to launch TIBCO Designer from Ant, and working on a project-by-project basis from within each project’s build script, will specify and control your file aliases, class paths and other settings. No more need to waste valuable time on incorrect file-aliases.
Property File to Engine Configuration Translation gives you the ability to specify BusinessWorks engine properties in simple property files. BWUnit then lets you use these files to generate AppManage-compatible configuration files for each of your environments and is even smart enough to tell you when you’ve forgotten to set a global variable, such as a database password for the production environment.
Service WSDL Generation saves time and money by removing the manual steps currently required to produce a concrete WSDL for Service defined within your project. Even more importantly, because it allows you to specify the global variables to use when generating the WSDL, you will be able to generate a correct WSDL for each environment.
This document will guide you through:
Throughout this document there are references to various testing phases, of which tend to have sligtly different meanings within different organisations.
For the purpose of clarity, we have decided to standardise based on their definition on Wikipedia as detailed below.
While the name used for the various testing phases are far from ideal (e.g., Integration Testing has a very different meaning for most integration developers), we consider them far better than custom phase names that no-one would be familiar with.
http://en.wikipedia.org/wiki/Unit_testing
Unit testing seeks to tests individual units of source code within a software project.
For TIBCO BusinessWorks, we regard a process as a unit and your unit tests should focus on testing your processes, not the end-points that expose them to other systems.
Within this context, it is very important to decouple the processes you are testing from the external systems they are dependant on, through the use of test doubles (stubs, fakes, mocks, etc). Decoupling is a very important step as unit test failures should indicate errors within the processes you are testing and not be dependant on components outside of the control of the BW project you are testing.
Failure to decouple the processes you are testing from their external systems can result in slow-running tests, erratic tests and test-run-wars.
More information on erratic tests and slow running tests and their impact is available at http://xunitpatterns.com/Erratic%20Test.html and http://xunitpatterns.com/Slow%20Tests.html .
http://en.wikipedia.org/wiki/Integration_testing
Integration testing seeks to combine individual software modules and tests them as a group. This term leads to much confusion within the BW development world (due to it's strong focus on integration of disparat systems) and should not be confused with integrating your software modules with external systems, the testing of which takes place in system testing.
For TIBCO BusinessWorks, we regard integration testing as the testing of your BW processes integrated with the starter processes or services that expose them to other systems and your integration tests should focus on testing the end-points that these starter processes or services expose.
As per unit testing, it is very important to decouple the _processes) you are testing from the external systems they are dependant on, through the use of test doubles (stubs, fakes, mocks, etc).
Integration test failures should indicate errors within the project's starter processes or services, assuming the processes they call have passed unit testing.
http://en.wikipedia.org/wiki/System_testing
System testing of software or hardware is testing conducted on a complete, integrated system to evaluate the system's compliance with its specified requirements.
As a rule, system testing takes, as its input, all of the "integrated" software components that have passed integration testing. The purpose of integration testing is to detect any inconsistencies between the software units that are integrated together (called assemblages). System testing is a more limited type of testing; it seeks to detect defects both within the "inter-assemblages" and also within the system as a whole.
For TIBCO BusinessWorks, we regard system testing as testing of your BW processes integrated with the starter processes or services that expose them to other systems and the systems that your project depends on.
Assuming the end-systems are operating correctly, system test failures should indicate errors within your sub-processes for communicating with those systems.
NOTE: Typically the interfaces tested and the tests used during System Testing are the same as those used during Integration testing, with the difference being the use of test doubles (stubs, fakes, mocks, etc) during Integration Testing and real backend systems during System Testing.
http://en.wikipedia.org/wiki/System_integration_testing
In the context of software systems and software engineering, system integration testing (SIT) is a testing process that exercises a software system's coexistence with others. With multiple integrated systems, assuming that each have already passed system testing, SIT proceeds to test their required interactions.
For TIBCO BusinessWorks, we regard system integration testing as testing the systems that depend on the end-points exposed by your project along with the systems that your project depends on. This is often referred to as end-to-end testing.
Assuming the systems that depend on your project are operating correctly and the end-systems your project depends on are operating correctly, system integration test failures should indicate errors with how your end-points are exposed to the consumers that invoke them. Typically this results from misunderstandings regarding interface specifications.
http://en.wikipedia.org/wiki/Acceptance_testing
In engineering and its various subdisciplines, acceptance testing is a test conducted to determine if the requirements of a specification or contract are met.
Specifically, acceptance tests are test that describe the behaviour of the system(s) from a business or end-user point of view. They should clearly articulate the behaviour of the integrated systems.
When System Integration tests are written so that they desribe and test the behaviour of the integrated systems then the System Integration tests can and should be considered acceptance tests.
More information on this approach can be found at http://en.wikipedia.org/wiki/Behavior-driven_development
Please see the SalesLeads project for examples of behavioural tests: https://github.com/windyroad/SalesLeads
The BWUnit homepage can be found at http://windyroad.com.au/software/bwunit/ . Community discussion forums for BWUnit can be found at http://windyroad.com.au/discussion/ and the Windy Road team is looking forward answer your support questions at http://windyroad.com.au/support/ .
More information about Apache Ant can be found at http://en.wikipedia.org/wiki/Apache_Ant and full documentation for Apache Ant can be found at http://ant.apache.org/manual/index.html
Please see either the BWUnit Lite End User License Agreement or the BWUnit Pro End User License Agreement supplied with this software. If a copy of BWUnit Lite End User License Agreement or BWUnit Pro End User License Agreement was not provided with this software, you may request a copy from http://windyroad.org/support/ .
BWUnit is compatible with the following software:
Name | Version |
---|---|
Apache Ant | 1.8.2 to 1.9.7 |
TIBCO BusinessWorks | 5.2 to 5.13.0 |
BWUnit should also work with newer versions of Apache Ant versioned as 1.X.Y and newer versions of BusinessWorks versioned as 5.X.Y, however at the time of this writing we have not tested BWUnit against any such newer versions. If you have any issues using BWUnit with newer versions of Apache Ant or TIBCO BusinessWorks, please contact Windy Road Support for assistance.
BWUnit is supported on the following platforms that BusinessWorks is supported on
BWUnit should also work on versions of HPUX and AIX that BusinessWorks is supported on, however we do not explicitly test BWUnit on those platforms. If you have any issues using BWUnit on HPUX or AIX please contact Windy Road Support for assistance.
Step one: Pick a BW project
Step two: Create a file called build.xml
in a folder above the BW project. e.g. We usually have the build.xml
located somewhere like <SomePath>\MyCoolBWProject\build.xml
and the actual BW code at
<SomePath>\MyCoolProject\src\main\bw\MyCoolProject
Step three: Add the following content to the build.xml
<?xml version="1.0" encoding="UTF-8"?> <project default="designer" name="MyCoolProject"> <import> <url url="http://windyroad.com.au/bwunit-importer/%%version%%/full.xml" /> </import> </project>
Step four: If you haven't already, install Apache Ant (http://ant.apache.org). Version 1.8.2 or newer will do.
Make sure it's installed correctly by opening a command prompt and running ant -version
.
Step five: From the same directory as your build.xml
run ant -p
on the command line to get a list of targets you
can run. You'll be asked a number of questions. If you make a mistake, it stores the answers in the
Configuration Settings files desribed below, which you can fix with a text editor.
Step six: From the same directory as your build.xml
run ant designer
, ant ear
and ant validate
. They should
all just work.
When you run BWUnit, it will look for configuration settings in the following files:
Filename | Description |
---|---|
${user.home}/${ant.project.name}.properties | Used to store developer specific settings for a specific project |
${user.home}/build.properties | Used to store developer specific settings for all projects, such as the Windy Road download server credentials |
${basedir}/build.properties | Used to store project settings that are the same for all developers |
${basedir}/ivy.xml | Used to specify project dependencies |
${basedir}/ivysettings.xml | Used to specify where project dependencies should be downloaded/copied from and built artifacts should be uploaded/copied to |
Where:
${user.home}
is your home directory
${ant.project.name}
is the value of the /project/@name
in your build.xml
${basedir}
is the directory containing your build.xml
If TIBant is unable to find the configuration setting it is looking for, it will ask you for the correct value for that
setting and store the value in either ${user.home}/build.properties
or ${basedir}/build.properties
.
NOTE: The following files should be added to you source control for the project
${basedir}/build.xml
${basedir}/build.properties
${basedir}/ivy.xml
${basedir}/ivysettings.xml
Property Name | Description | Default |
---|---|---|
bwda.bw.project.path | Path to your BW project code. | The relative path to the first directory found containing a vcrepo.dat file. |
bwda.build.dir | Path to the directory where BWUnit should place generated files. | build |
ivy.lib.dir | Path to the directory where BWUnit should download dependencies to. | lib |
bwda.classpath.dir | Path to a directory where BWUnit should look for JAR files to automatically include in the TIBCO executables classpaths. | lib |
bwda.aliases.dir | Path to a directory where BWUnit should look for PROJLIB files to automatically include as file aliases and design-time libraries. | lib |
ivy.organisation | Name of the company, department, group or individual that your project belongs to, typically in reverse domain name format. e.g., au.com.windyroad , org.apache . | com.example.integration |
bwda.expected.errors | The number of errors reported when your BW project is validated. | 0 |
bwda.max.warnings | The number of warnings reported when your BW project is validated. | 0 |
bwda.repo.dir | The absolute path to a shared directory where dependencies should be copied from and built artifacts should be published to. | none |
bwda.pipeline.version | The version of the project's artifacts that will be used to create a configuration or that will be deployed. | The most recent version in your artifact repository |
bwda.config.deploy.dir | The path to the directory where BWUnit should load deployment properties from. | config/deploy |
bwda.config.gvar.dir | The path to the directory where BWUnit should load global variable properties from. | config/gvar |
bwda.config.sdk.dir | The path to the directory where BWUnit should load Adapter SDK properties from. | config/sdk |
bwda.config.fail.on.unset.global.variables.@{ear} | If true BWUnit will fail the build if there are global variables in the EAR that are missing from the project's global variables properties files. | false |
bwda.config.fail.on.unknown.sdk.properties.@{ear} | If true BWUnit will fail the build if there are properties in the project's Adapter SDK properties files that are noT present in the EAR and will be ignored by BW. | false |
bwda.deployment.domain | The TIBCO Administrator domain that you wish to create a configuration for or deploy to. | none |
bwda.pipeline.${bwda.deployment.domain}.config.version | The version of the project's configuration for the specified domain that should be used during deployment. | The most recent version in your artifact repository for the version of the bwda.pipeline.version EARs for the specified domain. |
NOTE: All paths are relative to your ${basedir}
unless otherwise specified
NOTE: bwda.pipeline.version
, bwda.deployment.domain
and bwda.pipeline.${bwda.deployment.domain}.config.version
are not persisted by BWUnit and should be passed in from the command line or by your CI server.
BWUnit assumes that you will be using a shared directory to upload and download artifacts and dependencies. However
${basedir}/ivysettings.xml
can be modified to instead use a Maven-compatible artifact repository
(e.g. JFrog's Artifactory), ssh, sftp, subversion and more. Please see
http://ant.apache.org/ivy/history/latest-milestone/settings/resolvers.html and https://code.google.com/p/ivysvn/ for
more details or contact Windy Road support if you have any questions about artifact storage.
BWUnit will automatically download JAR files and PROJLIB files that are
specified as dependencies in your ${basedir}/ivy.xml
and configure designer
, buildear
, etc to use these files. Please see
http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependencies.html for more details on specifiying dependencies
or contact Windy Road support if you have any questions about specifying dependencies.
You can search for public JAR files that you can add as dependencies at http://search.maven.org/ or http://mvnrepository.com/
As of BWUnit v16, BWUnit provides a number of Apache Ant targets for performing typical tasks for a BW project.
Opens the project in TIBCO Designer. BWUnit will automatically retrieve the project's
dependencies (PROJLIB files and JAR files) as specified in the project's ${basedir}/ivy.xml
file and configure
Designer's classpath, design time libraries and file aliases accordingly.
Additional JAR files and PROJLIB file that cannot be downloaded/copied from your artifact repository can be configured as
file aliases by adding properties to ${basedir}/build.properties
in the following format:
engine.aliases.<NAME>.projlib=Z:/SomePath/To/<NAME>.projlib
or
engine.aliases.<NAME>.jar=Z:/SomePath/To/<NAME>.jar
Opens the project in TIBCO Designer with the tester pre-configured to use global variables and engine settings for the specificed system integration testing (SIT) environment.
NOTE: Typically we do not recommend connecting TIBCO Designer directly to SIT environments, however we do recognise that sometimes it is required for debugging purposes.
Opens the project in TIBCO Designer with the tester pre-configured to use global variables and engine settings for the specificed system testing (ST) environment.
NOTE: Typically we do not recommend connecting TIBCO Designer directly to ST environments, however we do recognise that sometimes it is required for debugging purposes.
Builds the project's EAR files and PROJLIB files. BWUnit will automatically determine what to build based on the
.archive
files and .libbuilder
files in your project. It will also automatically retrieve the project's
dependencies (PROJLIB files and JAR files) as specified in the project's ${basedir}/ivy.xml
file.
Additional JAR files and PROJLIB file that cannot be downloaded/copied from your artifact repository can be configured as
file aliases by adding properties to ${basedir}/build.properties
in the following format:
engine.aliases.<NAME>.projlib=Z:/SomePath/To/<NAME>.projlib
or
engine.aliases.<NAME>.jar=Z:/SomePath/To/<NAME>.jar
The built files will be created in ${bwda.build.dir}
.
Removes all the files in ${bwda.build.dir}
.
Removes the BWUnit license settings from ${user.home}/build.properties
. Execution of BWUnit Pro targets will prompt
you for your BWUnit license settings again.
Retrieves the version of the project's EARs specified by ${bwda.pipeline.version}
, extracts the template configuration files,
and builds configuration files for the TIBCO Administrator domain specified by ${bwda.deployment.domain}
.
Creates a copy of the BWUnit artifacts in the releases
repository as specified by he project's ivysettings.xml
The target repository can be controlled via the ${bwda.mirror.repo}
property.
Once a mirror has been created, projects may set ${bwda.local.resolve.only}
to true in order to completely remove
the windy road artifactory repositories from dependency resolution.
Performs the same function as create-mirror
, but just for the specified BWUnit license.
Retrieves the version of the project's EARs specified by ${bwda.pipeline.version}
, the version of the project's
configuration specified by, ${bwda.deployment.domain}
and ${bwda.pipeline.${bwda.deployment.domain}.config.version}
and deploys them to the TIBCO Administrator domain specified by ${bwda.deployment.domain}
.
If you are using TRA 5.7.3 or later, the deploy target will first upload the EARs and their configuration without restarting the BW engines. It will then proceed to perform a rolling restart of each BW instance, waiting for each instance to enter a state of "Running" before moving onto the next. In high availability (e.g. load balanced or fault tolterant) scenarios, this results in no-outage during the deployment.
If you are using an earlier version of the TRA, the deploy target will first upload the EARs and their configuration without restarting the BW engines. It will restart all of the BW instances belonging to the EAR, which will result in a short outage.
NOTE: The host on which this is run must be a member of the specified TIBCO Administrator domain.
NOTE: Even though the deploy target can provide a no-outage deployment in high availability secnarios, we strongly recommend that the deployment of critical systems into production environments be performed during a prescribed outage window, in-case there are any issues during the deployment, which result in an outage.
As per the build
target, except only EAR files will be built.
Takes a password as input and outputs an obfuscated result.
As per the build
target, except only PROJLIB files will be built.
Retrieves a "snapshot" version of a project's EARs and PROJLIBs specified by ${bwda.pipeline.version}
and republishes
them as "release" versions. This is used as a way to indicate that a version of a project's EARs and PROJLIBs have
passed applicable quality gates and have been deemed fit for production deployment.
As per configure-ear
and additionally the generated configuration files are uploaded/copied to your artifact repository.
As per build
and additionally the generated EARs and PROJLIBs are uploaded/copied to your artifact repository as "snapshot" versions.
Runs the BWUnit integration tests and generates reports indicating for each test if it passed or failed. Failed tests will not fail the build.
Runs the BWUnit system integration tests and generates reports indicating for each test if it passed or failed. Failed tests will not fail the build.
Runs the BWUnit system tests (i.e. runs the integration tests against a deployed engine) and generates reports indicating for each test if it passed or failed. Failed tests will not fail the build.
Runs the BWUnit unit tests and generates reports indicating for each test if it passed or failed. Failed tests will not fail the build.
Runs all the BWUnit tests. Failed tests will fail the build.
Runs the BWUnit integration tests. Failed tests will fail the build.
Runs the BWUnit system integration tests. Failed tests will fail the build.
Runs the BWUnit system tests (i.e. runs the integration tests against a deployed engine). Failed tests will fail the build.
Runs the BWUnit unit tests. Failed tests will fail the build.
Validates the project. TIBant will automatically retrieve the project's
dependencies (PROJLIB files and JAR files) as specified in the project's ${basedir}/ivy.xml
file and configure
Designer's classpath, design tiem libraries and file aliases accordingly.
As per build
, additional file aliases can be configured using engine.aliases.*
properties
BWUnit is extremely customisable and extendable to suit your particular needs. The following sections detail the Apache Ant custom tasks and macros provided by BWUnit. An understanding of Apache Ant is assumed. If you need help customising or extending BWUnit, please contact Windy Road Support.
BWUnit and it's example projects rely on the following software:
Apache Ant is a software tool for automating the software build processes. Ant uses XML to describe the build process and its dependencies. More information about Apache Ant can be found at http://en.wikipedia.org/wiki/Apache_Ant and documentation for Apache Ant can be found at http://ant.apache.org/manual/index.html
Apache Ant is required both during the BWUnit installation when using BWUnit. Apache Ant 1.8.2 or later is required.
TIBant provides a set of Apache Ant tasks for building and deploying TIBCO BusinessWorks projects. BWUnit builds upon TIBant, providing test automation capabilities and allowing you to create a completely automated continuous delivery pipeline for your BusinessWorks projects.
H2 is a fast, light-weight Java SQL database. It's ability to run as an in-memory database makes it ideal for unit and integration testing (leaving the use of production like databases for system testing, system integration testing and beyond). We recommend using H2 as a stub for databases your projects depend on. This allows you to test the logic within your project, without requiring access to a production like database.
Alternativly, you can stub databases using the dependency injection pattern. The Currency example uses the dependency injection pattern to stub a SOAP web service. The same pattern can be used to stub any external integration, including databases.
NOTE: Dependency injection is the preferred mechanism for stubbing. The use of H2 is suggested for times when you want to test existing DB dependant code that has not been written with Dependency Injection in mind, which you do not wish to refactor at this time.
More information about H2 can be found at http://www.h2database.com/html/main.html and the documentation for H2 can be found at http://www.h2database.com/html/quickstart.html
Apache ActiveMQ is an open source implementation of the supporting JMS 1.1 standard. It's support for running as an in-memory (A.K.A. embedded) JMS Server make it ideal for unit and integration testing (leaving the use of production like JMS implementations for system testing, system integration testing and beyond). We recommend using ActiveMQ as a stub for JMS intgrations your project depends on. This allows you to test the logic within your project, without requiring access to a the JMS clients your project depends on.
Alternativly, you can stub JMS integrations using the dependency injection pattern. The Currency example uses the dependency injection pattern to stub a SOAP web service. The same pattern can be used to stub any external integration, including JMS integrations.
NOTE: Dependency injection is the preferred mechanism for stubbing. The use of ActiveMQ is suggested for when you want to test existing JMS dependant code that has not been written with Dependency Injection in mind, which you do not wish to refactor at this time.
More information about Apache ActiveMQ can be found at http://activemq.apache.org/ and the documentation for Apache ActiveMQ can be found at http://activemq.apache.org/getting-started.html
The following conventions are used within this user guide:
Formatting | Description |
---|---|
code | Code fragments and command line examples are represented using this formatting. |
${property-name} | Is used to represent the value of a BWUnit Ant property |
${user.home} | Is used to represent your home directory. e.g., C:\Users\John Doe |
${ant.file.dir} | Is used to represent the directory containing your project's build.xml file |
To use BWUnit, the following software and it's dependencies are required:
Name | Version |
---|---|
TIBCO BusinessWorks | 5.2 or later |
Java | 1.5.0 or later |
Apache Ant | 1.8.2 or later |
NOTE: Though BusinessWorks 5.2 is compatible with Java 1.4.2, BWUnit requires Java 1.5.0 or later. If you need support for a version of Java earlier than 1.5.0, please let us know at http://windyroad.com.au/support/ .
NOTE: The validate-project
macro is not compatible with BW 5.2 as it uses the -a
option on
the validateproject
executable for specifying file aliases, which was not introduced until later versions of BW.
NOTE: Most of the BWUnit examples require BW 5.8 or later. The exception is the HelloWorld example, which is compatible with BW 5.2 and later.
We don't like complicated install processes. Simply copy the following into a build.xml
file in
a directory relative to your BW project
<?xml version="1.0" encoding="UTF-8"?> <project default="designer" name="MyBWProject"> <import> <url url="http://windyroad.com.au/bwunit-importer/16/importer.xml"/> </import> </project>
and run ant -p
from the command line (The Ant bin
directory will need to be in your path) or from your IDE.
The first time you run Ant using this script, it will request input for a number of project specific BWUnit settings.
These settings will be stored in ${user.home}/build.properties
and ${ant.file.dir}/build.properties
file
(i.e. in the same directory as the build.xml
file).
Alternatively, you can create the ${user.home}/build.properties
and ${ant.file.dir}/build.properties
files manually with the follow properties
(all paths are relative to the build.xml
file):
Property Name | Desc | Stored In |
---|---|---|
wr.repo.username | Your Windy Road Download server username | ${user.home}/build.properties |
wr.repo.password | Your Windy Road Download server password | ${user.home}/build.properties |
bwda.bw.project.path | Relative path to your BW project | ${ant.file.dir}/build.properties |
bwda.build.dir | The directory where BWUnit should store generated files | ${ant.file.dir}/build.properties |
bwda.lib.dir | The directory where BWUnit should store libraries and other dependencies (including BWUnit) | ${ant.file.dir}/build.properties |
bwda.classpath.dir | jar files in this directory will be added to Designer's and BW's class path | ${ant.file.dir}/build.properties |
bwda.aliases.dir | jar files and projlib files in this directory will be added to Designer's and BW's file aliases | ${ant.file.dir}/build.properties |
bwda.results.dir | The directory where BWUnit should store test reports | ${ant.file.dir}/build.properties |
bwda.expected.errors | The number of errors reported when the BW project is validated | ${ant.file.dir}/build.properties |
bwda.max.warnings | The number of warnings reported when the BW project is validated | ${ant.file.dir}/build.properties |
BWUnit/HTTP-service-port | The HTTP port BWUnit will use when running tests | ${ant.file.dir}/build.properties |
NOTE: The build.xml
file and the ${ant.file.dir}/build.properties
should be add to your source control repository
(with your BW project), so that these settings can be shared between developers and with your continuous integration server
The first time you run your BWUnit tests from Ant, you will also be prompted for your the following BWUnit Pro license settings:
Property Name | Desc | Stored In |
---|---|---|
bwunit.license.version | The date stamp of your BWUnit license | ${user.home}/build.properties |
bwunit.license.company | The company name BWUnit is licensed | ${user.home}/build.properties |
bwunit.license.holder | The name of the BWUnit holder | ${user.home}/build.properties |
If you are using BWUnit Lite, the above settings do not apply and you are limited to executing tests individually from within TIBCO Designer. The Lite version does not allow you to run the tests in an automated manner, nor does it allow you use any of the Ant macros/targets except for launching TIBCO Desginer (i.e. it does not permit use of the macros/targets for automated build, validation, deployment, configuration, etc).
As a developer, if you need to change any of the project specific BWUnit settings and you do not want those
settings to impact other developers, you can add the properties to either ${user.home}/${ant.project.name}.properties
or ${basedir}/build.properties
to have them apply to a specific project or all projects repectivly.
To get started testing quickly with BWUnit, use the steps above to configure your project, launch TIBCO Desginer
designer by running ant desginer
from the command line (or run the desginer
Ant target from your IDE),
and follow the steps below.
A Test Suite in BWUnit is used to logically group Test Cases and nested Test Suites. Create a Test Suite by creating a folder called "MyTestSuite" in your project in TIBCO Designer.
A Test Case in BWUnit is used to logically group Tests and to share a fixture between tests. Create a Test Case by creating a folder called "MyTestCase" in the "MyTestSuite" folder in your project in TIBCO Designer.
The easiest way to create is to copy the Test template in the BWUnit DTL. In TIBCO Desinger, find
BWUnit/Public/Templates/Test
, right click and select "Copy". Go back to MyTestSuite/MyTestCase
, right click and
select "Paste".
Load the test you created in the TIBCO Designer Tester, by selecting the "Tester" tab, pressing the green right arrow button, selecting the "Test" process you created and clicking "Load Selected".
Select Test.process in the Tester tab and click the "Create a job" button with the green process icon.
The Test.process will run and generate an error telling you test test has not been implemented
Stop the tester and delete the "AssertFail" activity in your test. Add a "Call Process" activity to your test and set the Process Name (in the Call Process "Configuration" tab) to a process you want to test; it's easiest to start with a process that produces an output that is determined by its' input. In the "Input" tab input some suitable test data.
Add an "AssertEqual" to your test by dragging it from "BWUnit/Public/Asserts/AssertEqual". Add transitions from "Start" to your "Call Process", from "Call Process" to "AssertEqual" and from "AssertEqual" to "End".
In the "Input" for "AssertEqual" map the output of "Call Process" to under "equal-input/actual". Build the output you expect from "Call Process" under "equal-input/expected".
Run the test like you did before and if your process produces the output you expected then the test will finish succefully. If not, the error will contain both the expected and actual values, which can be used to adjust the expected input.
BWUnit comes with a number of example projects that demonstrate different ways BWUnit can be used to test your projects.
The HelloWorld example provides a very basic example of how BWUnit can be used to unit test a BusinessWorks process.
The Simple example demonstrates how a H2 in-memory database (http://h2database.com/html/main.html) can be used to replace the need for a production like database during unit and system testing and to ensure the tests are repeatable. Similarly, it uses Apache ActiveMQ (http://activemq.apache.org/) in an in memory (A.K.A. embedded) mode to replacer the need for a production like JMS implementation during unit and system testing. It also contains a small number of tests to demonstrate answers to questions on TIBCommunity (https://www.tibcommunity.com) and StackOverflow (http://stackoverflow.com/).
The Currency example demonstrates how dependency injection (http://xunitpatterns.com/Dependency%20Injection.html) can be implemented with BusinessWorks, so that stubs can be used during unit and system testing, instead of relying on seperate systems. The Currency example also demonstrates how Integration Contract Tests (http://www.martinfowler.com/bliki/IntegrationContractTest.html) can be implemented, so that you can ensure that your stubs behave in a similar mannar to the systems they are stubs of.
Finally, the SelfTest example shows how BWUnit is used to test BWUnit.
== Advanced Configuring ==
BW engine properties to be used when the run-functional-tests
target is run can be set from within
Ant by creating a properties prefixed with engine.properties.
. For instance to enable job statistics, use:
<property name="engine.properties.bw.engine.jobstats.enable" value="true"/>
Often it is neccesary to disable certain processes starters during a test run. This can be done using the
Config.Primary.Partitions
engine property to limit the processes that are loaded. However when using this approach
you must include BWUnit.process
and all of your tests. For example the following code will enable the BWUnit
process starter, all of the tests, their dependencies and no other process starters.
<pathconvert property="engine.properties.Config.Primary.Partitions" dirsep="/" pathsep=","> <map from="${bwda.bw.project.path}" to="" /> <path> <pathelement location="${bwda.bw.project.path}/BWUnit.process" /> <fileset dir="${bwda.bw.project.path}" includes="**/*TestSuite/*TestCase/*.process" /> </path> </pathconvert>
Global Variables to be used when testing in Desginer and when the run-functional-tests
target is run, can be set
from within Ant by creating a properties prefixed with engine.gvars.
. For instance to set the DirLedger
global
variable use:
<property name="engine.gvars.DirLedger" location="${bwda.build.dir}/ledgers"/>
File Aliases to be used by Designer or when the run-functional-tests
, validate
or ear
targets are run, are
automatically set to the files within ${bwda.aliases.dir}
. You can add libraries in additional locations by creating
properties prefixed with engine.aliases.
. For instance to add Z:\shared\common-1.7.11.projlib
as an alias use:
<property name="engine.aliases.common-1.7.11.projlib" location="Z:/shared/common-1.7.11.projlib"/>
Otherwise, for complete control over the file aliases, create a propertyset with the id bwengine.aliases
. e.g.
<propertyset id="bwengine.aliases"> <propertyref prefix="myproject.aliases." /> <mapper type="glob" from="myproject.aliases.*" to="*"/> </propertyset>
Jar files located in ${bwda.classpath.dir}
will be automatically added the the class path for Designer and when you
run the ear
and validate
targets. Alternatively for finer control, you can set the bwda.bwengine.classpath
property to the desired classpath. For instance
<pathconvert property="bwda.bwengine.classpath"> <fileset dir="${bwda.classpath.dir}"> <include name="*.jar" /> </fileset> <fileset dir="Z:/shared/jars"> <include name="*.jar" /> </fileset> </pathconvert>
BWUnit Tests are arranged in a hierarchy, comprised of folders. Test Suites can contain Test Cases and other Test Suites. Test Cases can contain Tests and optionally a Fixture.
Test Suites represent a collection of Test Cases. To create a Test Suite, create a folder ending with
TestSuite
.
Test Cases represent a collection of Tests that shared a common Fixture. To create a Test Case,
create a folder within a Test Suite ending with TestCase
.
Tests contain the logic that verifies if your processes behave in the manner they are expected to. They provide a mechanism for encoding the requirements for the processes they test.
To create a Test:
BWUnit/Public/Templates/Test.process
into a Test Case.
Fixture
is permitted.
In the example above, a Call Process
activity is used to link a specific customer to an account.
Another Call Process
activity is then used to retrieve the accounts linked to that customer. An
Assert Equals
is then used to check the the customer is linked to the correct number of
accounts.
The example above is a unit test for AssertDoesNotEqual
. Each instance of AssertDoesNotEqual
is provided with a different input, to test different boundary conditions. When an error is
expected, there is a success transition to an AssertFail
and an error transition to an AssertEquals
,
which checks that the error generated matches the error we expect.
Asserts are used to confirm that the output of a call to a particular process is what is expected.
To add an assert to your test:
BWUnit generates test reports via the supplied report-functional-tests
Apache Ant target.
NOTE: TIBCO Hawk or TIBCO Administrator must have been configured for the local system using the domain name LOCAL
As described in the Installation Steps section, the bwda.results.bwunit.xml
, bwda.results.bwunit.html
and
bwda.results.junit.xml
properties are
used to specify where you want BWUnit to create the reports.
BWUnit also generates test coverage reports for BusinessWorks projects via the supplied run-functional-tests
Apache Ant
target. As described in the Installation Steps section, the bwda.results.emma.xml
property is
used to specify where you want BWUnit to create the report.
The coverage report is in Emma xml format, which is compatible with popular tools like Jenkins.
The following table lists the mapping between BW code concepts and how their equvilent in the Emma report
Emma Name | BW Name | Notes |
---|---|---|
Package | Folder | folder seperaters ('/') are replaced with stops ('.') |
Source File | Process | |
Class | Process | |
Method | Process | |
Block | Group | The ungrouped area in a process is counted as one group |
Line | Activity |
NOTE: Coverage of transitions is not reported at this time.
BWUnit is designed to work with your Continuous Integration server, such as Hudson, Jenkins, Bamboo
CruiseControl or ThoughtWorks Go. The provided report-functional-tests
Apache Ant target produces
JUnit compatible XML output, allowing your continuous integration server to clearly indicate which test(s)
failed and why. Simply configure your continuous integration server to call the run-functional-tests
target
and specify that the path to the JUnit formated test results.
For example, to have Jenkins run the tests and parse the test report with the default BWUnit settings, use:
Section | Field | Value |
---|---|---|
Build | Targets | report-functional-tests |
Post-build Actions | Publish JUnit test result report | checked |
Post-build Actions | Test report XMLs | build/test-results/TEST-*.xml |
The bwda.results.emma.xml
property used by the report-functional-tests
target specifies the location to
create the Emma (http://emma.sourceforge.net/)
compatible XML coverage report, which can also be integrated with your continuous integration server. The coverage
reports show you which processes and activites were and were not executed during the test run, so you can see which
parts or your code need more tests.
For example, to integrate the coverage reports with Jenkins using the default BWUnit settings:
build/test-results/coverage-*.xml
The Continuous Delivery book sets out the principles and technical practices that enable rapid, incremental delivery of high quality, valuable new functionality to users. Through automation of the build, deployment, and testing process, and improved collaboration between developers, testers, and operations, delivery teams can get changes released in a matter of hours— sometimes even minutes–no matter what the size of a project or the complexity of its code base. The website for the book can be found at http://continuousdelivery.com/
The xUnit Test Patterns book and website provide many unit testing patterns and approaches, along with anti-patterns or "smells". We highly recommend this book to anyone who is serious about unit testing. The website can be found at http://xunitpatterns.com/
© Windy Road Technology Pty. Limited 2009-2016. All Rights Reserved.
The following section details each of the Apache Ant macros provided by BWUnit
Starts a BusinessWorks engine locally, with BWUnit aliases
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
project | The name of the TIBCO Designer Project. e.g., MyProject | Yes | n/a |
dir | The directory the TIBCO Designer Project is in. e.g., src/bw | Yes | n/a |
aliases-refid | A propertyset refid for the file aliases needed by the project | No | empty-set |
global-variables-refid | A propertyset refid for the Global variables to use when running the project. See the | No | empty-set |
properties-refid | A propertyset refid for the properties to use when executing the BusinessWorks engine. For instance setting | No | empty-set |
working-dir | The working directory. e.g., build/working/@{project} | No | build/working/@{project} |
create-dtl-file | If true, create the
(Available since version 1.4.1) | No | false |
spawn | Whether or not you want the engine to be spawned. If you spawn the engine, its output will not be logged by ant. | No | false |
heap-size | Specifies the initial Java heap size to allocate | No | ${tibco.designer.heap.size} |
custom-cp-ext-prepend | Customizable Classpath information. All classes and jars in these directories will be automatically picked up. You can also specify individual files. Use forward slashes only. e.g., g:/a1/b1;d:/a2/b2/c.jar | No | %EXISTING-VALUE% |
custom-cp-ext-append | Customizable Classpath information. All classes and jars in these directories will be automatically picked up. You can also specify individual files. Use forward slashes only. e.g., g:/a1/b1;d:/a2/b2/c.jar | No | %EXISTING-VALUE% |
application-args | Other arguments to application, JVM etc. | No | |
timeout | The number of seconds the engine should run for before quitting.
This can be used to have the engine automatically terminate, in situations where
(Available since version 15) | No | -1 |
taskname | No | bwunit:bw-start |
Invokes a SOAP operation on a BWUnit BW engine to stop it
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
host | No | localhost | |
port | No | ${BWUnit/HTTP-service-port} | |
stop-max-wait | No | 60 | |
stop-max-wait-unit | No | second | |
stop-timeout-property | No | bwunit.stop.timeout | |
fail-on-stop-timeout | No | true | |
working-dir | The working directory for this macro. e.g., build/working | No | build/working |
taskname | No | bwunit:bw-stop |
_(Deprecated. Automatically coverted by the run-tests
macro.)_ Converts the specified BWUnit results file into HTML format
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
file | The BWUnit Results file to convert. | Yes | n/a |
tofile | The file to write the JUnit formated results to. | Yes | n/a |
failifmissing | Fail if | No | true |
_(Deprecated. Use the results-junit
attribute in the run-tests
macro.)_ Converts the specified BWUnit results file into JUnit format
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
file | The BWUnit Results file to convert. | Yes | n/a |
tofile | The file to write the JUnit formated results to. | Yes | n/a |
hostname | The hostname to insert into the results. | No | localhost |
failifmissing | Fail if | No | true |
Converts the specified BWUnit results file into NUnit format
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
file | The BWUnit Results file to convert. | Yes | n/a |
tofile | The file to write the NUnit formated results to. | Yes | n/a |
project | Name of the project that was tested | Yes | n/a |
failifmissing | Fail if | No | true |
Opens a project in TIBCO Designer, with BWUnit aliases
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
project | The name of the TIBCO Designer Project. e.g., MyProject | Yes | n/a |
dir | The directory the TIBCO Designer Project is in. e.g., src/bw | Yes | n/a |
aliases-refid | A propertyset refid for the file aliases needed by the project | No | empty-set |
global-variables-refid | A propertyset refid for the Global Variables to set prior to launching designer. The specified Global Variables will have their values replaced within the projects defaultVars.substvar files and the original values will be lost. USE WITH CAUTION! | No | empty-set |
properties-refid | A propertyset refid for the properties to use when running the project in the Designer Tester. For instance setting
(Available since version 12) | No | empty-set |
working-dir | The working directory to launch TIBCO Designer from. e.g., build/working/@{project} | No | build/working/@{project} |
create-dtl-file | If true, create the | No | true |
heap-size | Specifies the initial Java heap size to allocate | No | 256M |
custom-path | this will be prepended to tibco.env.PATH | No | %EXISTING-VALUE% |
custom-cp-ext | this will be prepended to tibco.class.path.extended | No | %EXISTING-VALUE% |
custom-palette-path | this will be prepended to java.property.palettePath | No | %EXISTING-VALUE% |
custom-lib-path | this will be prepended to tibco.env.LD_LIBRARY_PATH, tibco.env.SHLIB_PATH, tibco.env.LIBPATH | No | %EXISTING-VALUE% |
application-args | Specifies the remaining command line arguments to pass into the application -d : to activate the debug info dump -help : to print a list of acceptable command line arguments | No | |
coverage-exclusions | A comma seperated list of processes to exclude from the coverage report file. e.g., `/Some/Process.process,/Another/One.process
The BWUnit processes are automatically excluded from the coverage report. The exclusions listed here are in addition to the automatically excluded BWUnit processes. (Available since v14) | No | |
taskname | No | bwunit:designer |
Installs a BWUnit license locally
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
license | Your BWUnit license | Yes | n/a |
Starts a BusinessWorks engine locally and executes the project's BWUnit tests.
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
host | The host address used to communiticate with the BWEngine. e.g., localhost
NOTE: The engine is started on the localhost. This attribute can be use to communicate with the engine using a particular interface. | No | localhost |
port | The HTTP port used to communiticate with the BWEngine. e.g., 5454 | No | 5454 |
project | The name of the TIBCO Designer Project. e.g., MyProject | Yes | n/a |
dir | The directory the TIBCO Designer Project is in. e.g., src/bw | Yes | n/a |
aliases-refid | A propertyset refid for the file aliases needed by the project | No | empty-set |
global-variables-refid | A propertyset refid for the Global variables to use when running the project. See the | No | empty-set |
properties-refid | A propertyset refid for the properties to use when executing the BusinessWorks engine. For instance setting | No | empty-set |
working-dir | The working directory. e.g., build/working/@{project} | No | build/working/@{project} |
create-dtl-file | If true, create the | No | true |
heap-size | Specifies the initial Java heap size to allocate | No | 256M |
custom-cp-ext-prepend | Customizable Classpath information. All classes and jars in these directories will be automatically picked up. You can also specify individual files. Use forward slashes only. e.g., g:/a1/b1;d:/a2/b2/c.jar | No | %EXISTING-VALUE% |
custom-cp-ext-append | Customizable Classpath information. All classes and jars in these directories will be automatically picked up. You can also specify individual files. Use forward slashes only. e.g., g:/a1/b1;d:/a2/b2/c.jar | No | %EXISTING-VALUE% |
application-args | Other arguments to application, JVM etc. | No | |
result-dest-dir | (Deprecated. Use @{results-xml}, @{results-html} instead.) The directory to store the results. e.g., build/bwunit-results | No | build/bwunit-results |
results-xml | The file to write the BWUnit test results to as an XML file.
(Available since v14) | No | @{result-dest-dir}/results.xml |
results-html | The file to write the BWUnit test results to as a HTML file.
(Available since v14) | No | @{result-dest-dir}/results.html |
results-junit | The file to write the BWUnit test results to as a JUnit compatible XML file.
(Available since v14) | No | no output |
results-emma | The file to write the BWUnit test coverage to as an Emma compatible XML file.
(Available since v14) | No | no output |
coverage-exclusions | A comma seperated list of processes to exclude from the coverage report file. e.g., `/Some/Process.process,/Another/One.process
The BWUnit processes are automatically excluded from the coverage report. The exclusions listed here are in addition to the automatically excluded BWUnit processes. (Available since v14) | No | |
scope | (Deprecated.) The path within your BW Project to start looking for Test Suites. | No | / |
suite-pattern | (Deprecated.) The regex pattern to use when searching for test suites. e.g., | No | TestSuite$ |
case-pattern | (Deprecated.) The regex pattern to use when searching for test cases e.g., | No | TestCase$ |
fixture-pattern | (Deprecated.) The regex pattern to use when searching for fixtures e.g., | No | ^Fixture$ |
force | If | No | false |
failonerror | If | No | false |
failonmissingreport | If
(Available since v16) | No | false |
errorproperty | The property to set if @{failonerror} is true and the tests fail
(Available since v14) | No | bwunit.tests.failed |
license | If set, the provide license is installed prior to test execution. Otherwise the previoulsy install license will be used. | No | |
start-max-wait | The number of time units to wait for the BWEngine to start before executing the tests. If the BWUnit service port is not available after the specified number of time units, the test run will abort and the | No | 120 |
start-max-wait-unit | The unit of time to wait for the BWEngine to start before executing the tests. If the BWUnit service port is not available after the | No | second |
start-timeout-property | The property to set if the BWUnit port is not available after the specied wait period. | No | bwunit.start.timeout |
stop-max-wait | The number of time units to wait for the BWEngine to stop after executing the tests. If the BWUnit service port in still available after the specified number of time units, the | No | 60 |
stop-max-wait-unit | The unit of time to wait for the BWEngine to stop after executing the tests. If the BWUnit service port is still available after the | No | second |
stop-timeout-property | The property to set if the BWUnit port is still available after the specied wait period. | No | bwunit.stop.timeout |
timeout | The number of seconds the engine should run for before quitting.
This can be used to have the engine automatically terminate, in situations where
(Available since version 15) | No | -1 |
taskname | No | bwunit:run-tests |
Allows you to validate resources within a TIBCO BusinessWorks Project, with BWUnit aliases.
NOTE: On Linux based systems an X-server is required to run the validate executable that this macro uses. On headless systems Xvfb can be used to meet this requirement: http://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml
(Available since version 1.6)
Parameters specified as attributes.
Name | Description | Required | Default |
---|---|---|---|
project | The name of the TIBCO Designer Project. e.g., MyProject | Yes | n/a |
dir | The directory the TIBCO Designer Project is in. e.g., src/bw | Yes | n/a |
expected-errors | The number of errors expected during validation. If the number of validation errors does not equal this value then the macro will fail.
Normally you whould not change this from 0, however there are times when a project produce validation errors (e.g. when using the
NOTE: The macro will fail if there are less errors than expected. This is to prevent situations where you have a number of expected validation errors, and then someone makes a change which results in one of them being removed. At this point, unless this macro fails, it would be possible for new unexpected validation errors (that have not been confirmed to operate correctly) to be introduced. | No | 0 |
max-warnings | The maximum number of warnings permitted during validation. If the number of validation warnings exceeds this value then the macro will fail. | No | unlimited |
aliases-refid | A propertyset refid for the file aliases needed by the project | No | empty-set |
working-dir | The working directory. e.g., build/working/@{project} | No | build/working/@{project} |
create-dtl-file | If true, create the | No | false |
out | The output file for the validation results, build/working/@{project}/validation.log | No | build/working/@{project}/validation.log |
force | Force the re-validation of the project, even if it has not changed. | No | false |
heap-size | Specifies the initial Java heap size to allocate | No | ${tibco.designer.heap.size} |
custom-path | the value to use for | No | %EXISTING-VALUE% |
custom-cp-ext | the value to use for | No | %EXISTING-VALUE% |
custom-palette-path | the value to use for | No | %EXISTING-VALUE% |
custom-lib-path | the value to use for | No | %EXISTING-VALUE% |
application-args | Specifies the remaining command line arguments to pass into the application
| No | |
taskname | No | tibant:validate-project |