Create LeanFT tests in ALM

This topic includes information on creating a LeanFT test that can be run from ALM. You can use the LeanFT ALM APIs in your tests to retrieve information on ALM that is important to you. Aside from creating the tests in LeanFT, you also need to create parallel tests in ALM, as described in Create LeanFT tests in ALM.

Set up your LeanFT project

  1. In LeanFT, create a LeanFT project containing one or more test methods. For details, see Create a LeanFT testing project or module.

    • These test methods can be defined in a single .cs or .java file, or in multiple files within your project.
    • Use LeanFT ALM APIs in your test script.
  2. Compile the DLL or create the JAR.

LeanFT ALM APIs

LeanFT includes a set of comprehensive methods for retrieving information on your ALM environment, such as the ALM project name or the ALM server domain name. This capability is supported for all ALM testing frameworks (JUnit, NUnit, and TestNG).

You can retrieve information for both regular test runs and business components runs.

Retrieve ALM information using the getAlmRunInfo method in the ALMUtils class.

Example:  

AlmRunInfo runInfo = AlmUtils.getAlmRunInfo();

The getAlmRunInfo method returns an AlmRunInfo class when the test is run from ALM. If the test is not run from ALM, it returns NULL.

Retrieve business component information using the getBusinessComponentRunInfo method in the AlmRunInfo class.

Example:  

AlmRunInfo almRunInfo = AlmUtils.getAlmRunInfo();
if (almRunInfo != null) {
	BusinessComponentRunInfo bcRunInfo = almRunInfo.getBusinessComponentRunInfo();
}		

The getBusinessComponentRunInfo method returns a bcRunInfo class when the test is run from ALM. If the test is not run from ALM, it returns NULL.

For details on all the properties you can retrieve, see the .NET and the Java SDKs.

For full code examples, see Code examples.

Create LeanFT tests in ALM

Each test method in your LeanFT project that you want to run in ALM must be mapped to an ALM LEANFT-TEST test.

This can be done in one of the following ways:

Manually create LEANFT-TEST tests in ALM Create a LEANFT-TEST test in ALM for each test method in your LeanFT test script.
Import LeanFT tests into ALM

Use the import tool to create LEANFT-TEST test for multiple test methods simultaneously.

Recommended if you want to migrate a large number of test methods to ALM.

Manually create LEANFT-TEST tests in ALM

  1. In the ALM Test Plan module, create a test, and select the LEANFT-TEST test type.

  2. In the test plan tree, select the LEANFT-TEST test you just created.
  3. In the Test Script tab of the test, define your test. Provide values for required fields, as follows:

    Framework

    Select the framework you are using.

    JAR/DLL Path

    The path of the .jar or .dll file containing your test.

    Specify either a full file path or a path relative to that specified in the <TestAssetsDir> element of the LFTRemoteAgent.exe.config file.

    Fully Qualified Class Name

    The fully qualified name of your class, including the namespace (NUnit/MSTest) or package (JUnit/TestNG).

    Syntax: <package/namespace name>.<classname>

    Test Method Name

    The name of the LeanFT test method that your ALM test will run.

    Example:  

    Repeat for each test method that you want to include in your ALM test plan.

Import LeanFT tests into ALM

Use the LeanFT Test Export tool to export your test methods. Then, on the ALM side, use the LeanFT Test Import tool to import the test methods into ALM LEANFT-TEST tests.

  1. From the command line, run the export tool relevant to your testing framework. These are located in the <LeanFT installation>\Tools\TestExportTool folder.

    The export tool generates an XML file with the same name and in the same location as the DLL or JAR you provided.

    Example: C:\LeanFT\MyJUnitTests.xml.

  2. In ALM, in the Test Plan module, run the ALM import tool:

    1. Select Tests > Import LeanFT Tests.

    2. Select the XML file generated with the export tool in LeanFT and click Open.
    3. Select the test methods to import and click Import.

      Example:  

      A LEANFT-TEST test is created for each selected test method, with all required fields defined.

Back to top

Code examples

The following are full code examples for creating a test using the ALM APIs.

.NET examples

Java examples

Back to top

Next steps: