Generate application model code

This topic includes information on the different ways to generate application model code.

Methods for generating the code file

Application models include two types of files: an XML file (.tsrx) and a code file (.tsrx.cs or .java). The code file is generated from the XML file. For details, see Overview.

The code file can be generated in the following ways:

  • The UFT Developer IDE plugin automatically generates the code file when the testing project is opened in the IDE.
  • Using a command line tool. This method is recommended when you want to generate the code file or multiple code files without opening your testing projects. For details, see AppModel code generation tool.
  • For Maven-based projects, we recommend that you use the Maven plugin (Mojo). Use this method to automatically generate the code when the project is built. For details, see Maven application model generator plugin.

Back to top

AppModel code generation tool

Use the AppModel code generation tool to generate the application model code files. This is a useful method when you upgrade OpenText Functional Testing for Developers, especially when dealing with multiple files. For details, see Upgrade.

There are two tools: one for Java and one for C#. Use the one relevant for your project.

Run the tool for every project that includes an application model.

You can run the tool in one of the following modes:

  • Single file mode. Generates a single application model from a single .tsrx file.
  • Source folder mode. Generates application models for all .tsrx files under the Source folder.

To run the Java tool

Location:

Windows: <Installdir>\Tools\AppModelCodeGenerator\Java\

Linux/Mac: <Installdir>/Tools/appmodel-code-generator/Java

Single file mode format:

java -jar appmodel-code-generator.jar <tsrx path> -package <package name> -outputDir <output directory> -inPlace -sdk <sdk standalone jar>

Source folder mode format: 

java -jar appmodel-code-generator.jar <Source folder path> -outputDir <output directory> -inPlace -sdk <sdk standalone jar>

To run the C# tool

Location:

Windows: <Installdir>\Tools\AppModelCodeGenerator\DotNet\

Single file mode format:

AppModelCodeGenerator.exe <tsrx path> -namespace <namespace name> -outputDir <output directory> -inPlace -sdk <sdk dll>

Source folder mode format: 

AppModelCodeGenerator.exe <Source folder path> -namespace <namespace name> -inPlace -outputDir <output directory> -sdk <sdk dll>

Back to top

Maven application model generator plugin

The Maven application model generator plugin can be used to automatically generate application model code whenever a Maven-based project is built.

Perform the following for each Maven-based project.

Dependencies

The application model code generator Mojo is dependent on the following JARs:

  • OpenText Functional Testing for Developers common and SDK JARs.

    Make sure that they are installed in your local or remote repository. For details, see Prerequisites for Maven-based projects.

  • AppModel code generator (helper) JAR.

    To deploy the JAR to your organization's repository, run the following command:

    mvn deploy:deploy-file

    -DpomFile=<path-to-pom>

    -Dfile=<path-to-file>

    -DrepositoryId=<id-to-map-on-server-section-of-settings.xml>

    -Durl=<url-of-the-repository-to-deploy>

    To install the JAR to your local repository, run the following command:

    mvn install:install-file

    -Dfile=<path-to-file>

    -DpomFile=<path-to-pomfile>

    The path to the JARs and POMs is:

    • Windows: <Installdir>\Tools\AppModelCodeGenerator\Java
    • Linux/Mac: <Installdir>/Tools/appmodel-code-generator/Java
    JAR POM
    appmodel-code-generator-helper.jar

    appmodel-code-generator-helper-pom.xml

To configure the plugin

  1. Install the Mojo to your Maven repository. (Follow the instructions in Dependencies.):

    appmodel-code-generator-mojo-2024.4.0.jar

    appmodel-code-generator-mojo-2024.4.0-pom.xml

  2. Enable the plugin.

    Open the project pom.xml file and uncomment the Application model generator plugin section.

  3. (Optional) Configure where the generated code file is placed.

    By default, the file is generated under the appmodels folder in the project.

    To change the location:

    1. Copy the following code into the configuration element in the Maven plugin section in the pom.xml:

      <!--The output directory of the generated application models.The Default is the appmodels folder under the project-->
      <!--<outputDir>set_path</outputDir> -->
      <!--If set to true, the  application models are generated next to the tsrx files. Mutually exclusive with the outputDir parameter -->
      <!--<inPlace>true</inPlace> -->
    2. Uncomment either the outputDir or the inPlace element, and edit as required.
  4. Save your changes to the file.

Back to top

See also: