# Create a LeanFT testing project or module

Create a testing project or module using a built-in LeanFT template or using your own custom framework.

In this topic:

## Overview

The LeanFT plugin in your IDE comes with built-in LeanFT project or module templates. These provide a preliminary structure for your testing projects and references to the LeanFT files you need. They also enable you to use the functionality provided with the framework for developing test code and running your tests.

The LeanFT plugin must be installed on your IDE. Typically, IDE plugins are installed during the LeanFT installation process. However, you can also install them at any time. For details, see Maintaining and uninstalling LeanFT.

Note: You can install the LeanFT plugin on one or more Eclipse, Spring Tool Suite, or JBoss Developer Studio packages deployed on the same machine. To do this, see our blog post: How to install the LeanFT Eclipse plugin for multiple Eclipse packages deployed on the same machine.

Back to top

## LeanFT project templates for Visual Studio (Windows only)

In Visual Studio, you can create NUnit or MSTest LeanFT test projects and test items.

You can also create a project that enables you to develop Selenium tests with extended capabilities. For details, see LeanFT for Selenium.

Create an NUnit/MSTest project

1. If you are creating an NUnit project, make sure that you have a supported version of the NUnit framework installed. For details on supported NUnit versions, see the Product Availability Matrix. To download NUnit , see the NUnit download site.

   Note: In NUnit 3, the NUnit Runner and the NUnit framework are installed separately. Make sure to install the NUnit framework, preferably through the NuGet package manager.

2. Create a new project. Select Visual C# > Test project, and then either the LeanFT NUnit or MSTest project templates.

3. To add a test item in the project, in the Solution Explorer, right-click the project and select Add LeanFT.

What's included in the NUnit/MSTest LeanFT project templates?

- Reference to the HP.LFT.SDK and related HP.LFT.* elements (project template only)

- Reference to Microsoft.CSharp and, for LeanFT NUnit projects, nunit.framework (project template only)

- App.config, which enables you to customize certain test settings (project template only). For details, see Customize test settings.

- A basic LeanFtTest.cs template where you write your code (project and item templates).

  The exact structure of this template depends on whether you are using NUnit or MSTest. In both cases, they include attributes where you can define:

  Setup code | Runs once at the start of the class
  Setup code | Runs once at the start of each test
  Individual test units | The template includes a single `[Test]` (NUnit) / `[TestMethod]` (MSTest) attribute containing an empty `Test()` / `TestMethod()` method. You can rename this method to whatever you want to call your test. You can add multiple `[Test]` / `[TestMethod]` attributes if you want to include several tests in your class. Each `[Test]` / `[TestMethod]` attribute should declare a void test method that contains the main code for that test.
  Cleanup code | Runs at the conclusion of each test
  Cleanup code | Runs once at the end of the class

- UnitTestClassBase.cs, which controls what happens during the various phases of your run, including running and closing the LeanFT runtime engine (project template only).

Example: A new LeanFT NUnit project in Visual Studio:

- For details on using the MSTest framework, see the relevant MSDN documentation.
- For details on using the NUnit framework, see the NUnit documentation.

Back to top

## LeanFT project templates for IntelliJ IDEA and Eclipse

In IntelliJ IDEA and Eclipse (including also Spring Tool Suite and JBoss Developer Studio), you can create the following projects:

JUnit and TestNG

These projects can be:

- Maven-based: Include resources for running your tests with Maven.
- Selenium-based: Include resources for integrating with Selenium.

Cucumber

The Cucumber template is based on the Java testing framework (JUnit) and is Maven-based. For details on creating a LeanFT Cucumber project, see LeanFT with Cucumber.

Prerequisites

Before you create a Java project, review the following prerequisites:

- If you are creating a Selenium project, review Prerequisites for Selenium projects.

- If you are creating a Maven-based project, review Prerequisites for Maven-based projects.

- If you are using Eclipse, Spring Tool Suite, or JBoss Developer Studio, do the following:

  To create or work with... | Download and deploy or install...
  --- | ---
  LeanFT JUnit projects | The JUnit framework. Download from https://github.com/junit-team/junit/wiki/Download-and-Install
  A TestNG project | The TestNG plugin. For installation details, see TestNG Eclipse plugin.
  Maven-based projects using Eclipse Kepler Standard Edition | The M2Eclipse plugin. For installation details, see M2Eclipse.

- If you plan create a project that is based on the JUnit 5 template, make sure that you have the following installed:

  Java 8 |
  IntelliJ IDEA 2017.2.5 or higher | If you are working with IntelliJ.
  Eclipse Oxygen 4.7.1a or higher | If you are working with Eclipse.

Create a Java test project

1. In your IDE, create a new project.

   In the New Project wizard:

   1. Create a LeanFT > Testing project.

      IntelliJ IDEA users: Ensure that the correct Project SDK is selected.

   2. Follow the wizard, selecting the relevant options for your project:

      All projects | Provide the project name and location.
      Selenium | Select Selenium. Non-Maven based project: Provide the location of your Selenium JAR files.
      Non-Maven-based project | Provide the package name (Eclipse)/base package (IntelliJ IDEA), for example: com.microfocus.lft.
      Maven-based project | Provide the Group ID and Artifact ID, and the Maven version. IntelliJ IDEA users: If you are creating a Maven-based project, a message appears prompting you to Add as Maven project. Click the link to create the Maven-based project.
      JUnit | Select the JUnit version.

2. If you are using a JUnit 5 framework, note that the JUnit 5 libraries are not distributed automatically by LeanFT or by the IDE.

   - In Eclipse, the JUnit jars are automatically downloaded when the project is created.

   - In IntelliJ IDEA, for Non Maven-based projects: Once your project created, you will need to reconcile this issue by adding them manually:

     Expand the imports section, click the IDE suggestion, and then select Add JUnit5.0 to classpath.

     On the Download Library from Maven Repository, dialog box, click OK.

3. Eclipse, Spring Tool Suite, and JBoss Developer Studio users: Add test cases using the New LeanFT Test Case wizard (New > Other > LeanFT > LeanFT Test Case), selecting the relevant options for your test case.

4. Maven-based project: The project is created with a pom.xml file. Open this file in a text editor and configure your organization's Maven repository details:

       <repository>
       	<id>MyMVNrepo_ID</id>
       	<name>MyMVNrepo_name</name>
       	<url>http://MyMVNrepo_URL</url>
       </repository>

   Note: To run the Maven-based test using Maven, there are some additional configurations you need to apply to the pom.xml file. For details, see Run LeanFT tests.

What's included in the LeanFT JUnit/TestNG project templates?

- A basic LeanFtTest.java template where you write your tests. The exact structure of this template depends on whether you are writing a JUnit or TestNG script. In both cases, it includes attributes where you can define:

  Attributes for defining | Description
  --- | ---
  Setup code | Runs once at the start of the class
  Setup code | Runs once at the start of each test
  Individual test units | The template includes a single `@Test` annotation containing an empty `test()` method. You can rename this method to whatever you want to call your test. You can add multiple `@Test` annotations if you want to include several tests in your class. Each `@Test` annotation should declare a void test method that contains the main code for that test.
  Cleanup code | Runs at the conclusion of each test
  Cleanup code | Runs once at the end of the class

- UnitTestClassBase, which controls what happens during the various phases of your run, including running and closing the LeanFT runtime engine.

- References to the respective JUnit/TestNG jar files.

- The resources\leanft.properties file, which enables you to customize certain test settings. For details, see Customize test settings.

- References to the com.hp.lft.sdk, com.hp.lft.report, com.hp.lft.unittesting, com.hp.lft.verifications, and com.hp.lft.reportbuilder-standalone libraries.

- TestNG: Includes a TestNG.xml configuration file. For more details about setting up this file, please refer to the TestNG documentation.
- Maven-based: Includes the pom.xml file that provides all the information that Maven needs to build the project.
- Selenium: Includes the Selenium JARS and the LeanFT Selenium (Java) SDK.

Example: A new LeanFT JUnit project in Eclipse:

Example: A new LeanFT JUnit project in IntelliJ IDEA:

LeanFT Java files and UTF-8 encoding

LeanFT Java files use UTF-8 encoding, so you must make sure that any Java files you use in your project are also UTF-8 or UTF-8 compatible.

Maven users: To compile your LeanFT Java projects using Maven, you must specify the encoding either in the pom.xml or in the Maven command line.

1. To add the encoding to the pom.xml, add the following:

       <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>

2. To specify the encoding in the command line, use:

       mvn clean install -Dproject.build.sourceEncoding=UTF-8

For details on using the JUnit framework, see the JUnit documentation.

Back to top

## LeanFT module template for Android Studio

For Android Studio, you can create a LeanFT module.

The LeanFT module template is based on JUnit, but includes enhancements to help you create mobile tests easily.

To create a LeanFT module

1. If you are working with a Maven repository, follow the instructions in Prerequisites for Maven-based projects.
2. Open the project to which you want to add the LeanFT module.
3. In Android Studio, click File > New > New LeanFT Module.

4. On the Create New LeanFT Module dialog box, enter the Module name and the Java package name, and then click Finish.

   A LeanFT module is created with all the required resources.

5. If you are working with a Maven repository, open the module's build.gradle file, and follow the instructions in the file.
6. If you are working with LeanFT from your file system and not with a Maven repository and you want to use the LeanFT JavaDoc, you need to add it manually from the Library Properties of the LeanFT SDK jar.

What's included in the LeanFT module template for Android Studio?

- A LeanFtTest.java template where you write your tests.

  The template includes setup code, tear-down code, and a single `@Test` annotation containing an empty `test()` method.

  Rename this method to whatever you want to call your test. You can add multiple `@Test` annotations if you want to include several tests in your class. Each `@Test` annotation should declare a void test method that contains the main code for that test.

- The resources\leanft.properties file, which enables you to customize certain test settings. For details, see Customize test settings.

- UnitTestClassBase, which controls what happens during the various phases of your run, including running and closing the LeanFT runtime engine.

- References to the com.hp.lft.sdk, com.hp.lft.verifications, and com.hp.lft.sdk.mobile libraries.

- build.gradle scripts.

Back to top

## JavaScript template for supported IDEs

You can write JavaScript tests using any of the supported IDEs.

For a starting template for JavaScript tests, see Setting up and working with the JavaScript SDK.

Back to top

## Custom template

If you are using a custom framework:

1. Ensure that your project references a number of items from the LeanFT SDK library.

2. Set up your project as described in Use your own frameworks with LeanFT.

Back to top

Next steps:

- LeanFT test objects
- Run LeanFT tests
- Analyze run results

https://admhelp.microfocus.com LeanFT 8942
Tips to improve your search results...TOC Lean Functional Testing Help Center LeanFT Help Center 14.50 - 14.53 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version:(Undefined variable: _rscC_Basic_Variables.FloatingTocShow)