Skip to main content

Enhance Robot Framework with functional-style keyword chaining. Streamline test cases by piping output of one keyword as input to another, simplifying data flow and readability.

Project description

robotframework-pipe

Version License

Introduction

Pipe is a Robot Framework Library that brings the pipe operator known from functional programming languages into Robot Framework. PipeLibrary is designed to enhance keyword chaining capabilities, it simplifies the process of passing the output of one keyword as an input to another, enabling more readable and maintainable test cases.

Installation

To install PipeLibrary, run the following command:

pip install robotframework-pipe

Usage

Here's a basic example to demonstrate the usage of the PipeLibrary:

*** Settings ***
Library    PipeLibrary

*** Test Cases ***
Complex Operation With Pipe
    Pipe    Get User Id    username
    ...    >>    Fetch User Details
    ...    >>    Process Data
    ...    >>    Validate User
    ...    >>    Log

Without Pipe, the same example would require intermediate variables:

Complex Operation Without Pipe
    ${user_id} =    Get User Id    username
    ${user_details} =    Fetch User Details    ${user_id}
    ${processed_data} =    Process Data    ${user_details}
    ${status} =    Validate User    ${processed_data}
    Log    ${status}

The PipeLibrary simplifies the process by removing the need for intermediate variables and making the flow of data between keywords more intuitive and cleaner.

Syntax Explanation

  • Pipe: The main keyword of the PipeLibrary.
  • >>: The pipe operator, used to chain keywords.
  • Placeholder: A symbol (default $) used to denote where the output of the previous keyword should be placed in the next keyword's argument list. This is optional.

By default, the result of the keyword is used as the first argument of the next keyword. You can use the Placeholder to explicitly set the argument or import the PipeLibrary with the argument pipe_strategy=append to use the result as the last argument by default.

Examples

You can find more examples in the /tests directory.

Using Placeholder

My Test Case
    Pipe    Sum    1    2
    ...    >>    Subtract    4    $
    ...    >>    Should be Equal As Integers    1

In this example, $ is replaced with the result of Sum, so Subtract is called as Subtract 4 3.

Configuration

You can initialize the library with custom settings:

*** Settings ***
Library    PipeLibrary    pipe_strategy=append    placeholder=$    pipe_operator=>>

Note

Currently, PipeLibrary does not support keyword syntax highlighting and autocompletion in the Robot Framework environment. This is due to the dynamic nature of the pipe operator and the way arguments are passed between keywords.

Contributions

Contributions to PipeLibrary are welcome! If you have suggestions for improvements or have identified a bug, please feel free to open an issue or submit a pull request on our GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_pipe-0.1.2.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

robotframework_pipe-0.1.2-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page