Friday, August 20, 2010

Unit testing Oracle SCA Composites

With Oracle SOA 11g we have a unit testing framework available for testing the individual components. This enables us to test the components in isolation without any external dependencies like availability of target services. This in turn helps during integration testing as we already have well tested low level components.

The framework allows :
1. Definition of Tests, assertions and emulations via Jdeveloper
2. Deployment of test cases along with deployment of SCA composite
3. Execution of test cases from EM console.

A typical testcase may contain an initiated message, an emulation which defines message/error
returned by an external reference/service and/or an assertion which is primarily used for comparison against expected results.

Below I have shown an example where I tested a component (AIA RequestorABCS) which had a DB adapter as initiator of process and called an external target service like SAP R/3. Now for unit testing this piece I used an initiator message in my test suite and an emulator to define a response message from SAP R/3. This way I don't have to depend on availability of actual target system at time of unit testing my ABCS code.

The test suite can be created from Jdeveloper :







It creates a copy of the composite.xml as shown below.














Once completed, deploy the test suite along with normal SCA deployment from Jdev/ant scripts and execute it from EM Console as shown below.

No comments:

Post a Comment