First Steps

This document describes how to record and run a simple unit test and covers the following topics:


Before you Begin

Make sure you have the following:

  • License for Natural Screen Tester

  • Software AG Designer

  • Local or remote Natural application to test

See Prerequisites for complete list of system prerequisites.

Glossary of Terms

Assertion

An assertion encapsulates some testable logic specified about a target under test. This can be an attribute-value pair, for example "firstName":"John", or a true-false statment inserted in a program where the developer always expects a certain condition, for example "endOfList":"true". Assertions are stored in the generated JSON file.

Configuration File

Each test project has a configuration file in JSON format. This contains default values for the packages contained in the test project, for example "hostApplication":"my_Mainframe".

Host

The host containing the application you want to test.

Input

Field identified as input field when the test case is recorded, for example User ID. Inputs are stored in the generated JSON file.

JSON File

In Natural Screen Tester, a JSON file (JavaScript Object Notation) is generated by the Generate Unit Test wizard from the test project. It contains inputs and assertions for the unit test as attribute-value pairs. You can copy a generated JSON file and change the inputs and assertions. The unit test is then run multiple times, once for each JSON file.

Test Case

A test case corresponds to an individual function, for example LoginFlow or GetUserById. It is the result of the recorded screen flow. From a recorded test case you can generate a unit test.

Test Project

A test project corresponds to the Natural application you want to test. It consists of one or more test cases.

Unit Test

A unit test is generated from a recorded screen flow, for example LoginFlow. A unit test is generated as a test case to a new test project or added to an existing test project. The unit test is run from the Java file that is generated in the test project.

Creating your First Unit Test

This section covers the following topics:

Step 1: Create a New Test Project

Start of instruction setTo create a new test project

  1. From the Software AG Designer, open the Natural Screen Tester development environment.

  2. Connect to the Natural Screen Tester server by double clicking the server icon. A new dialog for credentials is opened.

    graphics/firstSteps_create_new-2.png

  3. In the Natural Screen Tester perspective, create a new test project. Select Screen Tester Server, and from the context menu choose New Test Project.

    graphics/firstSteps_create_new-3.png

  4. Enter a name for your new project, a description and specify the initialization mode. Press Next. See Test Project Configuration Parameters in the Natural Screen Tester Reference Guide.

  5. Under General Test Project Information, specify your Natural host.

Step 2: Identify Screens and Fields for your Test Case

Start of instruction setTo identify screens and fields

  • See Screens in the Designing and Developing a Test Case documentation.

Step 3: Record your Test Case

Start of instruction setTo record your test case

  1. Under the Sessions folder, double-click the Default session to start the green screen host session of the test project. During this session you record the screen flow of the test case.

    graphics/firstSteps_create_record-1.png

  2. Record the screen flow that covers the test case. graphics/pathrec.gif

  3. During recording, mark the fields you want to include as inputs for your test case. graphics/input_container.gif

  4. During recording, mark the fields you want to include as assertions for your test case. graphics/output_container.gif

  5. Stop the recording. graphics/pathstop.gif

  6. In the Define Test Case Name screen, enter a name, description and folder where the test case will be stored.

Step 4: Generate a Unit Test

Start of instruction setTo generate a unit test

  1. Review the test case to make sure the inputs and outputs were recorded correctly. You can also edit or add logic to the recorded test case to make it more general or specific to suit your needs.

  2. Select the test case and choose Generate Unit Test.

    The following artifacts are generated:

    • Java project that includes a Java file containing the executable test case

    • JSON configuration file

    • JSON file containing inputs and assertions

    • required binary files that are included in the Java project

Step 5: Run the Unit Test

Start of instruction setTo run the unit test

  • From the Java perspective, select the generated Java file. From the context menu choose Run as > JUnit Test.