Testing with Maven

Starting with v9.2, you can use the Maven plug-in to run Functional Test scripts. Apache Maven is a software build tool based on the concept of a project object model (POM). You can use the Maven plug-in that is provided to run tests as part of your Maven build.

Note: This is an experimental feature in 9.2.

Introduction

To automate testing with Maven, you must configure a POM file that is delivered with the product installation package and launch the test from command line using Maven command.

Before you begin

  • You must have installed HCL OneTest UI and set up an environment variable that points to the installation directory.
  • You must have installed Maven and set up an environment variable that points to the M2_HOME directory.
  • You must have a functional test.

Downloading FT-Maven plug-in

Maven plug-in is included in the product installation. The plug-in contains a POM.XML file. The first time you execute this file, Maven will automatically download the plug-in from a local repository. You can use this file to execute your tests, or use and rename the ft_pomSample.XML file sample file that is delivered in the product package.

Configuring the sample POM file

A sample file ft_pomSample.XML file is delivered with the product installation. It is saved in /SDP/maven2 folder. The file contains all types of dependencies as well as arguments required to execute the script. You just need to copy this file in your directory and modify below arguments, datasource and other optional values.
Note:

DataStore and script name arguments are required.

Arguments ftArgs and scriptArgs are optional, they must be used only if it is required by the script.

Arguments mentioned in the POM.XML file:
<arguments>
<argument><!-- Specify DataStore path (Mandatory) --></argument>
<argument><!-- Specify script name to be executed (Mandatory) --></argument>
<argument><!-- Provide ftArgs if any (Optional) --></argument>
<argument><!-- Provide scriptArgs if any (Optional) --></argument>
</arguments>
In the following example, the script name is Script1 and datasource (project) is drive:/MyName/Project1, so the modified arguments are:
<arguments>
<argument>drive:/MyName/Project1</argument>
<argument>Script1</argument>
<argument><!-- Provide ftArgs if any (Optional) --></argument>
<argument><!-- Provide scriptArgs if any (Optional) --></argument>
</arguments>

Running the tests

  • Maven automatically identifies the POM file. So if the .xml file name is POM.XML, then execute the tests with the mvn test command, otherwise use the appropriate command as shown in the following table:
  • Table 1. Command line to run the tests:
    Command Description
    mvn test If file name is POM.xml and you are in same directory.
    mvn test -f filename.xml If file name is other than POM.xml and you are in the same directory
    mvn test -f FULL_PATH\fileName.xml If you are in a different directory and POM.xml or use a .xml file with other name in a different directory, provide the full path.
When the tests are executed, Maven will display any type of exception if it occurs while executing the tests. The errors are related to the following scenarios:
  • File name you have provided.
  • Required parameters missing.
  • Any wrong argument.
  • Any exception occurred while executing scripts.

FT-Maven plug-in will just indicate whether the test was executed successfully or not. Reports and logs are not showing up once the test execution is completed. To see the reports, you need to check the log folder in HCL OneTest UI log folder. The log will show in the explorer mode if it is disabled in FT-maven plug-in.

Use cases

Script including script name only, with no option.
<arguments>
<argument>drive:/MyName/Project1</argument>
<argument>Script1</argument>
</arguments>
Script including argument as option.
<arguments>
<argument>drive:/MyName/Project1</argument>
<argument>Script1</argument>
<argument>scriptArgs1 scriptArgs2 scriptArgsN</argument>
</arguments>
Script including ftArgs related options only. You can add whatever options you need here.
<arguments>
<argument>drive:/MyName/Project1</argument>
<argument>Script1</argument>
<argument>-rt.log_format html -log testLogFolder -iterationCount 10</argument>
</arguments>
Script including all options.
<arguments>
<argument>drive:/MyName/Project1</argument>
<argument>Script1</argument>
<argument>-rt.log_format html -log testLogFolder -iterationCount 10</argument>
<argument> scriptArgs1 scriptArgs2 scriptArgsN</argument>
</arguments>