Getting Started

This document covers the following topics:

General Information

This is a brief introduction to working with the Application Testing component of NaturalONE. It explains how to test a simple subprogram, how to save it as a unit test file, and how to generate an Ant script from the unit test file. You can then use the Ant script, for example, with your automated nightly tests. It is assumed that you use the local RPC server which is automatically started when you start NaturalONE.

Testing business services is not in the scope of this introduction. However, this works similarly.

The topics below assume that you have created a Natural project which uses the local Natural runtime. This Natural project contains a library with two objects, a subprogram and a parameter data area (PDA).

Test Project

Testing is illustrated using the following simple subprogram:

#result := #var1 + #var2

where the subprogram calls the following PDA:

 1 #var1 (I4)
 1 #var2 (I4)
 1 #result (I4)

Do not forget to build your Natural project before you start testing.

Testing a Subprogram Directly

When you test a subprogram directly, you can analyze the parameters in a test editor. You can change the input values, run the test, and verify the return values.

Start of instruction setTo test a subprogram

  1. In the Navigator view, select the subprogram.

  2. Invoke the context menu and choose Testing > Test Subprogram.

    The test editor appears.

    Test editor

  3. Select the entry for #var1 on the left side of the test editor.

    Properties are now shown on the right side of the test editor.

  4. Define a value for #var1 on the right side. Example:

    Value for #var1

  5. Select the entry for #var2 on the left side of the test editor, and define a value on the right side.

  6. Choose the Run test (Run Test) button in the local toolbar of the test editor.

    The result value is now shown. Example:

    Value for #result

Creating a Unit Test

After defining the input and output parameters for the test, you can save this as a unit test.

Start of instruction setTo create a unit test

  1. Make sure that the editor with your previous test is active.

  2. From the File menu, choose Save As.

    The New Natural Unit Test dialog appears.

    New Natural unit test

    The name of the subprogram is automatically provided as the name for the unit test. For now, you need not change any information.

  3. Choose the Finish button.

    A folder named Testing-Suites is automatically created in the project. This folder is always created when you create the first unit test in a project.

    The unit test is stored in the new Testing-Suites folder. Unit tests for subprograms (also called "Natural unit tests)" have the extension .nattst.

    Testing-Suites folder

    The generated unit test file is automatically shown in the unit test editor (provided that you have not deselected the Display generated file(s) in the New Natural Unit Test dialog).

    Unit test editor

    The Summary tab shows the information that will be used for the test.

    You can save the test for later reuse. For example, you can use it as the basis for an Ant script. Before you save the test, however, you have the possibility the change information on the following tabs:

    • Summary
      You can allow a test to pass with an expected error.

    • Connection
      You can define a different RPC environment for your test.

    • Input
      You can change the input fields that are to be sent to the server.

    • Validation
      You can configure the fields that are to be tested after the call to the server has been made.

    Detailed information these tabs is provided later in this documentation.

  4. Use the standard Eclipse functionality to save your changes. For example, press CTRL+S.

Running a Unit Test

After you have created the unit test, you can run it in order to check whether it works as expected.

Start of instruction setTo run a unit test

  • Choose the Run test button in the local toolbar of the unit test editor.

    In the Navigator view, select the file with the extension .nattst, invoke the context menu and choose Testing > Run Unit Test(s).

    The Natural Unit Test view is automatically opened the first time you run a unit test. Example:

    Natural Unit Test view

    When the test was successful, the state "passed" is shown.

Generating an Ant Script

You can generate XML-based Ant scripts which run your unit test files.

Start of instruction setTo generate an Ant script

  1. In the Navigator view, select the unit test file you have previously created (that is, the file with the extension .nattst).

  2. Invoke the context menu and choose New > Other.

  3. In the resulting dialog box, expand Software AG > Testing and then choose Natural Unit Test Ant Script.

    The following dialog appears.

    New Ant script for Natural unit test

    For now, leave the provided settings as they are.

  4. Choose the Finish button.

    The following files are created in the Testing-Suites folder:

    • build.xml

      This file contains the Ant script. It is automatically opened in the Ant editor, and you can now refine the Ant parameters as desired. Detailed information on these parameters is provided later in this documentation.

    • run.cmd

      This file contains the DOS commands for running the script. You run this file outside of Eclipse via the command line.