Taurus Documentation

repository·master·Indexed 24 days ago

https://github.com/blazemeter/taurus

Taurus is an open-source, automation-friendly wrapper that provides a unified YAML-based interface for performance and functional testing tools, including JMeter, Gatling, Locust.io, Selenium WebDriver, Apache Benchmark (ab), and Apiritif. It simplifies test execution via the `bzt` CLI, supporting configuration overrides, custom reporters like TaurusReporter for Playwright, and integration with Robot Framework and NUnit.

Tokens
60.4K
Snippets
215
Records
304
Agent score
82%

What's inside Taurus

  1. What is Taurus?

    master

    Taurus is an automation-friendly convenience wrapper designed to hide the complexity of performance and functional tests. It acts as an abstraction layer over several underlying industry-standard tools:

    • Performance Testing: JMeter, Gatling, and Locust.io
    • Functional Testing: Selenium WebDriver

    Taurus is free and open source under the Apache 2.0 License.

  2. Proxy Server Auto Setup OS Support

    master

    The ability for Taurus to automatically configure proxy settings for recording depends on your operating system:

    • Linux: Full support for Chrome and Firefox.
    • Microsoft Windows: Supports Chrome (requires manual chromedriver path configuration as described in the setup guide).
    • MacOS: Auto setup is currently not implemented.
  3. What is Taurus and how does it work with Selenium and JMeter

    master
    Taurus is an open-source framework that provides a simplified way to create and run performance tests. It acts as an orchestration layer that integrates with existing open-source functional and performance testing tools such as Selenium, Gatling, or JMeter. Taurus uses YAML files for configuration, making test definitions easy to understand and manage within Continuous Integration (CI) pipelines.
  4. Control execution flow with Logic Blocks

    master

    Taurus provides several logic blocks to control the test flow, which are compiled into JMeter Controllers:

    • if: Conditional execution based on JMeter-formatted conditions. Requires then (and optional else) blocks.
    • once: Executes a block only once per thread.
    • loop: Repeats a block a specific number of times or forever.
    • while: Repeats a block while a condition is true.
    • foreach: Iterates over a collection of values extracted via an extractor.
    • transaction: Wraps requests in a transaction for grouping results.
    • include-scenario: Reuses an existing scenario within another.
    • action: Performs thread actions like pause, stop, stop-now, or continue.
  5. Set JMeter Properties and Variables

    master

    Taurus allows you to pass properties and variables to JMeter at different levels of granularity.

    JMeter Properties

    Properties can be defined globally (module-level) or locally (scenario-level). Scenario-level properties take priority and are merged into the global set.

    • Global Properties: Defined under modules.jmeter.properties.
    • Scenario Properties: Defined under scenarios.<name>.properties.
    • System Properties: Defined under modules.jmeter.system-properties.

    Use the JMeter syntax ${__P(property_name, default)} to access these in your scripts.

    Scenario Variables

    Variables are defined under scenarios.<name>.variables and can only be used at the scenario level. They are accessed using ${variable_name} syntax.

    execution:
    - concurrency: ${__P(my_conc,3)}
      ramp-up: 30
      hold-for: ${__P(my_hold,10)}
      scenario: with_prop
    
    modules:
      jmeter:
        properties:
          my_conc: 10
          my_hold: 20
        system-properties:
          sun.net.http.allowRestrictedHeaders: "true"
    
    scenarios:
      with_prop:
        requests:
        - http://blazedemo.com/${__P(sub_dir)}
        properties:
          my_hold: 15   # scenario-level property has priority
          sub_dir: contacts
      sc_with_vars:
        variables:
          subdir: contacts
          ref: http://gettaurus.org
        requests:
        - url: http://blazedemo.com/${subdir}
          headers:
            Referer: ${ref}
  6. Use the Selenium Executor for functional tests

    master

    The Selenium executor allows you to run functional tests locally using Selenium WebDriver. It supports multiple test runners and automatically detects the test type based on the file extension or folder structure. Taurus can also loop the test suite execution for a specified number of iterations or until a hold-for time is reached.

    Supported test runners include:

    • Java: junit, testng
    • Python: apiritif, pytest
    • Ruby: rspec
    • JavaScript: mocha
    • C#: nunit, xunit
    execution:
    - executor: selenium
      scenario: simple
  7. Implement the ScenarioExecutor lifecycle phases

    master

    A custom executor must implement five specific phase methods to manage the lifecycle of the testing tool. The phases are designed in mirrored pairs to ensure resource cleanup.

    MethodPurpose
    prepare()Load configuration and prepare the executor for launch. Use this to open resources.
    startup()Start the test executor process (e.g., launch a subprocess).
    check()Check if the test executor process has finished. Returns True if finished.
    shutdown()Shut down the executor process (e.g., terminate the subprocess).
    post_process()Finalize the executor and close all opened resources.

    Lifecycle Guarantee: If prepare() is called, the engine guarantees that post_process() will be called, ensuring that resources opened in prepare() are properly closed.

  8. Build JMeter test plans from configuration

    master

    Taurus can automatically generate JMeter scripts from a YAML configuration using the requests element. A scenario containing requests allows you to define a sequence of steps that Taurus translates into underlying tool scripts (like JMeter). Scenarios are defined in a top-level scenarios element and referenced in the execution block by their alias.

    scenarios:
      get-requests:  # the alias for scenario
        requests:
        - http://localhost/1
        - http://localhost/2
    
    execution:
    - scenario: get-requests  # alias from above is used
  9. Use Locators to find web elements

    master

    Apiritif uses several locator types to identify elements on a webpage. You can use these in short-form actions (e.g., clickByID(my_id)) or the alternative syntax with a locators list.

    Supported Locator Types:

    • ID: Matches the id attribute (e.g., id: my_id).
    • Name: Matches the name attribute (e.g., name: inputName).
    • CSS Selector: Uses standard CSS patterns (e.g., css: .controls or css: #inputName). Supports child selectors like div.controls>input#inputName.
    • XPath: Uses XML path language (e.g., xpath: //div/input).
    • LinkText: Matches the visible text of a link.
    • Shadow Locator: Used to access elements inside a Shadow DOM. It is composed of a sequence of CSS selectors where the last one is the target and preceding ones are the shadow hosts (e.g., shadow: c-basic, lightning-accordion-section, .slds-button).
  10. Taurus Configuration Structure Overview

    master

    A Taurus configuration is a dictionary containing several top-level keys that define the test execution, reporting, and environment.

    Key sections include:

    • execution: Declares tools to be executed, scenarios to use, and concurrency settings.
    • scenarios: A dictionary of scenario specifications with aliases.
    • reporting: A list of reporting modules to process results.
    • services: Configuration for service modules.
    • modules: A dictionary of classes to load and their respective settings.
    • settings: Top-level tool settings.
    • provisioning: Advanced option for distributed high-load testing (requires a provider).
    • included-configs: A list of additional configuration files to merge.
    execution:
    - concurrency: 10
      hold-for: 5m
      ramp-up: 2m
      scenario: sample
      
    scenarios:
      sample:
        headers:
            Connection: close
        requests:
        - http://localhost/
    
    reporting:
    - module: final-stats
    - module: console
    
    modules:
      jmeter:
        path: ./local/jmeter
        properties:
            log_level: DEBUG
      console:
        disable: false
        
    settings:
      check-interval: 5s
      default-executor: jmeter
    
    provisioning: local