IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Validating the code > Testing the adapter in unmanaged mode

JUnit: an open source framework for unit testing

JUnit is becoming the standard tool for unit testing in Java™ development environments. JUnit allows you to quickly and easily integrate automated regression testing into your coding and build processes.

With JUnit, an open source unit test framework, you can write and run tests for your adapter implementation. You use a simple setup() method to prepare each component for testing. Each test method can contain one or more assertions. The assertions test actual results against expected results. Using JUnit assertions, you can achieve a high degree of code quality and responsiveness to requirements outside of the adapter runtime environment.

A simple JUnit test case resembles the following:

public class MyTest extends TestCase {
    protected void setUp() throws Exception {
        super.setUp();
    }     public testSomething() throws Exception{
	String result = classUnderTest.executeSomething();
	assertEquals(result,"Something");
     } }

The setUp() method is called once before each test method. The purpose of the setUp() method is to prepare the component for the test. You can create several test methods; each must begin with the word test and contain at least one assertion.

The next section shows how to use the setUp() method to prepare your adapter for testing, and how to use the test methods to run functions. Because the goal is to test the adapter in unmanaged mode, run the adapter outside of a JCA container.

Validating the adapter in unmanaged mode–testing the adapter as part of development, gradually building the test case suite to address requirements–is a first step. This prepares the adapter for managed testing in a runtime environment. It also yields useful artifacts: the test case suite remains useful after unit testing because changes in code that break the functionality are tracked, alerting you when testing future iterations inside the development environment.

For more information about JUnit, see http://junit.org.

Testing the adapter in unmanaged mode