NeoLoad as-code

Through NeoLoad as-code, users can define or override a test project elements without launching a Controller. When running automated tests, this allows:

Also, NeoLoad as-code is easy to use with GIT version control.

How to use NeoLoad as-code

Command line

Configuring a test with NeoLoad as-code can be carried out with the command line. The -project argument allows declaring the NeoLoad project (".nlp") to launch. For more information, see -project in List of arguments.

-project can be run in command line, then test elements can be declared by specifying the corresponding YAML file(s) as described in Using one single file and Using multiple files below.

-project can also be used for each file as an alternative to putting all files after -project. For example, both examples below can be used:

-project "<path>/myproject.nlp" "<path>/servers.yaml" "<path>/user_paths.yaml"

or

-project "<path>/myproject.nlp" -project "<path>/servers.yaml" -project "<path>/user_paths.yaml"

Using one single file

All the elements of a test project can be included in a single "Project" YAML file as illustrated below:

name: MyProject
variables:
- file:
    name: products
    path: data/list_of_products.csv
    is_first_line_column_names: true
servers:
- name: mypc
  host: mypc.intranet.company.com
user_paths:
- name: MyUserPath
  actions:
    steps:
    - request:
        url: http://www.company.com/select?name=${products.col_0}
    - think_time: 1s
    - request:
        server: mypc
        url: /valide
populations:
- name: MyPopulation
  user_paths:
  - name: MyUserPath
    distribution: 100%
scenarios:
- name: MyScenario
  populations:
  - name: MyPopulation
    constant_load:
      users: 500

For more information, see the Project definition YAML syntax in the YAML syntax documentation.

Also, when using one single YAML file, the command line looks like:

NeoLoadCmd.exe -project "<neoload projects path>/MyProject/MyProject.nlp" "<neoload projects path>/myproject.yaml" -launch MyScenario
Using multiple files

When using NeoLoad as-code, each element of a test configuration such as variables, servers, User Paths, Populations and Scenarios can be provided in a separate YAML file. Right after declaring the project to launch with the -project argument, the YAML file(s) containing the project elements can be declared as described in the example below:

NeoLoadCmd.exe -project "<neoload projects path>/MyProject/MyProject.nlp" "<neoload projects path>/myproject-variables.yaml" "<neoload projects path>/myproject-servers.yaml" "<neoload projects path>/myproject-userpaths.yaml" "<neoload projects path>/myproject-populations.yaml" "<neoload projects path>/myproject-scenarios.yaml" -launch MyScenario

The example above allows launching a test including the "MyScenario" scenario and the variables, servers, User Paths and Populations elements each one included in a YAML file.

For more information about the YAML syntax for NeoLoad test elements, see the YAML syntax documentation.

Use case: Overriding Scenario settings for an automated test

In this use case, the user will use a YAML file describing the Scenario to use instead of the existing one in a NeoLoad project.

The YAML file to use for the scenario settings to apply is:

scenarios:
- name: MyScenario
  populations:
  - name: MyPopulation
    constant_load:
      users: 500
      duration: 15m

When having the same name, the scenario included in the YAML file replaces the scenario existing in the NeoLoad project. Also, if the scenario available in the YAML file does not exist in the NeoLoad project, it is then added in the project. In this example, we consider that a "Myscenario" scenario already exists in the NeoLoad project, is is then replaced by the scenario of the same name specified in the YAML file.

The user can then run the following command line:

NeoLoadCmd.exe -project "<neoload projects path>/MyProject/MyProject.nlp" "<neoload projects path>/myproject-scenarios.yaml" -launch MyScenario