NeoLoad as-code

NeoLoad as-code is a Domain-specific Language (DSL) for YAML and JSON to describe load testing scripts (NeoLoad User Paths), variables, and other test execution settings.

These as-code files can be:

  • checked in to source code, just like any other automation artifacts
  • refactored / reused so that SCM changes are versionable/testable/traceable
  • run in tandem with classic NeoLoad Desktop Designer (.nlp) projects
  • dynamically written during pipeline execution

Why NeoLoad as-code

Some people just like to work in code. Many developers and automation engineers live in their IDE or editor of choice and why should load testing be any different?

Much of the early surface area for modern development is around APIs, and therefore API testing is a huge part of modern software delivery cycles and validating their performance shouldn’t be hard.

Using NeoLoad as-code and the NeoLoad CLI connects this type of early work into the rest of the performance and load testing capabilities that the NeoLoad Platform has to offer. Starting with NeoLoad as-code for API testing also:

  • encourages earlier discussions about SLAs, environments, and test data
  • eases transition of test assets from early dev/test checks to downstream activities
  • fits in perfectly with highly automated processes such as CI pipelines
  • provides traceability and proof of performance requirements fulfillment
  • enables templating and standardization of process for performance testing

Examples

There are a ton of examples from our training workshops in the ‘neoload-as-code’ repo, but below is the general gist of how writing as-code YAML DSL flows.

Write and edit load tests confidently

Example as-code YAML DSL from training module 1

Training / Workshops

The video and deck used for our public training workshop on 2021-03-04 are below:

Getting Started

To write NeoLoad as-code YAML DSL, you will need:

  1. A modern IDE or text editor of your choice

    NOTE: Preferably something that supports JSON Schema for YAML such as:

  2. The NeoLoad CLI

    TO INSTALL follow these steps which require:

DSL Schema Support

To have YAML and as-code DSL specific text validation as well as autocomplete features, you will need to have the YAML extension installed and configure.

JSON Schema to use: https://raw.githubusercontent.com/Neotys-Labs/neoload-models/v3/neoload-project/src/main/resources/as-code.latest.schema.json

File patterns to use:

  • */.nl.yaml
  • **/default.yaml

You may also want to run NeoLoad CLI to validate your file as well when you save.

  • An example of this in VS Code is to install the ‘Run on Save’ extension and configure it in your settings.json file.

VS Code Configuration

File -> Preferences -> Settings -> Extensions -> Scroll down and find “Edit in settings.json”

Or in these paths in your OS:

  • Windows %APPDATA%\Code\User\settings.json
  • macOS $HOME/Library/Application Support/Code/User/settings.json
  • Linux $HOME/.config/Code/User/settings.json

A reference example settings.json file can be found here.

VS Code JSON Schema Configuration for as-code

IntelliJ Configuration

Preferences > Languages & Frameworks > Schemas and DTDs > JSON Schema Mappings

IntelliJ JSON Schema Configuration for as-code

Additional CI and CLI workshops

🔝