Generating JUnit Tests

Introduction

To fully provide an automatic migration feature we must implement a new functionality to allow a user to generate a JUnit tests based on selected Entity or Service.

The main aspect is to generate Junit Tests without re-generation the model or service.

Step-by-Step Guide

Starting the JUnit Test Dialog

  1. To generate tests for SDK projects, right click on an RPC entity file or Screen entity (trail) file.

  2. To generate tests for API projects, right click on a Service Interface.

  3. To generate tests for API Project services, the dialog will be called twice, once for the service and once for the Service\Controller, to create two different test files.  The OpenLegacy category will appear in context in the right-click menu.

  4. After right-selecting the file, click OpenLegacy → “Generate Junit Tests”. This is the entry point for all JUnit test generation.

















  5. The Generate Test dialog box opens.

  • Dialog Box Details

    • Path to Selected File

    • Output Test Filename (generated automatically according to the Entity name or enter your file name manually)

    • Generate Trail File (available only for Screen entities. It generates trails files for tests)

 

 

 



 

This dialog shows that a test file with that name already exists, and suggests several options:

  • “Override” button. The existing test file will be overridden.

  • “Generate New” button. A new test file will be created, and a seed will be added to the file name. For example: The output test file name is “EntityTest.java”, but a test file already exists with this name. The new file will be generated as “EntityTest_1.java”

  • “Cancel” button. Abort the generation process