Unit Test Framework

Introduction

The Unit Test Framework is a new testing solution designed for Iguana Professional and Iguana Enterprise. It allows you to create and run unit tests for your shared modules. Doing this helps you to ensure that you won’t accidentally break your interfaces when making changes or adjustments to your shared code.

To access the Unit Test Framework, please please contact us at support@interfaceware.com.

Configuring Your Tests [top]

  1. The first step will be to create your Test Configuration channel. This will be the channel where you will write your tests for each of your shared modules. Give your channel a name and click Create.
  2. In the sidebar on the left is a menu titled Shared Modules. This will list all of the shared modules that you have created on this instance of Iguana. From here you have the ability to create a test module for any of the listed shared modules by clicking the Create Test button. Doing this will create a Translator link which will navigate you to your test module.
  3. Clicking the translator link will jump you into the translator for your Test Configuration channel. You’ll notice that there is a new Local tests folder, with a test module that has the same name as the shared module you want to write tests for. You’ll also notice that your targeted shared module has been imported in the shared folder.
  4. In the tests module, you’ll see stub code that’s been generated for suite and individual setup and teardown functions. The setup and teardown functions allow you to initialize data that you might need to run through your tests. This could be data from a database, or an HL7 message.
  5. You’ll also notice that stub code has been generated for each shared function. This is an effort to have basic test coverage for the shared functions. Unit tests for shared functions are built using the assert function built into Lua.

From lua.org: “The assert function checks whether its first argument is not false and simply returns that argument; if the argument is false (that is, false or nil), assert raises an error. Its second argument, the message, is optional, so that if you do not want to say anything in the error message, you do not have to. Beware, however, that assert is a regular function. As such, Lua always evaluates its arguments before calling the function.

To create a test case, simply use assert and then give it any argument that you expect to fail. This could be an incorrect message mapping, or a function call with one argument when it expects two. Try to anticipate any data that might get passed to your shared functions so that you can have an extensive list of tests to cover any possible cases.

Running the Tests [top]

  1. Once we have a suitable library of tests, we can run them to see if they pass or not. To run our tests from the UT page we can click the link on the left hand toolbar that says Test Page.
  2. The Test Page displays a list of all of the tests that we have created for our shared modules. Tests will only show up here if you clicked the grey Create Tests button on the Shared Modules page.
  3. From the Test Page we can select individual tests to run by clicking the check box next to its name, or we can run all of them by selecting the check box at the top.
  4. Once the tests run, this page will tell us which ones passed, and which failed. It will also provide Translator links for us to navigate directly to each test.

For more information on the Iguana Packages, please contact your account manager or visit our Iguana Packages page.

Leave A Comment?