Gauge Documentation Release 0.9.8

Gauge Team

Apr 20, 2018

Contents

1 Windows 3 1.1 Using Chocolatey...... 3

2 MacOS 5

3 Linux 7 3.1 On Debian, Ubuntu...... 7 3.2 On RHEL, Fedora, CentOS...... 7

4 Alternate Methods 9 4.1 Offline Installation...... 9 4.2 Nightly installation...... 10

5 Plugins 11 5.1 Language runner...... 11 5.2 Reporting plugin...... 12

6 Verify your installation 13

7 Uninstallation 15 7.1 Gauge...... 15 7.2 Plugins...... 16

8 Quick start 17 8.1 Prerequisites...... 17 8.2 Creating a Project...... 17 8.3 Running the specs...... 18 8.4 Interpret results...... 18

9 Long Start 19 9.1 Why Gauge?...... 19 9.2 Gauge Terminologies...... 19

10 Using Gauge 29 10.1 Command Line Interface...... 29 10.2 Project Structure...... 44 10.3 IDE Support...... 48

i 11 Syntax 69 11.1 Specification...... 69 11.2 Scenario...... 69 11.3 Tags...... 69 11.4 Concept...... 70 11.5 Steps...... 70 11.6 Parameters...... 70 11.7 Special Parameters...... 70 11.8 Comments...... 71 11.9 Images...... 71 11.10 Links...... 71

12 Plugins 73 12.1 Required Plugins...... 73 12.2 Language/Reporting Plugins...... 73 12.3 IDE plugins...... 75 12.4 Build Tools...... 75

13 Language Features 77 13.1 Step implementations...... 77 13.2 Execution hooks...... 79 13.3 Data Store...... 83 13.4 Taking Custom Screenshots...... 86 13.5 Custom messages in reports...... 87 13.6 Enum as Step parameter...... 88 13.7 Continue on Failure...... 88

14 Reports 91 14.1 HTML Reports...... 91 14.2 XML Report...... 92 14.3 Spectacle...... 93 14.4 Flash...... 96

15 Configuration 97 15.1 Global...... 97 15.2 Local (Project level)...... 98 15.3 Environments...... 98 15.4 Language Plugin...... 100 15.5 HTTP Proxy...... 101 15.6 Build tools...... 102

16 Troubleshooting 109 16.1 Logs...... 109 16.2 Gauge Installation...... 109 16.3 Plugin installation...... 110 16.4 Execution...... 111 16.5 Intellij idea plugin...... 111

17 Examples 113 17.1 Basic...... 113 17.2 Web Application...... 113

18 HOWTOs 115 18.1 Integrating Gauge with CI/CD tools...... 115 18.2 Gauge tests on docker...... 122 ii 19 FAQs 125 19.1 Installation...... 125 19.2 Execution...... 126 19.3 IDE...... 126 19.4 JS FAQs...... 128 19.5 Python FAQs...... 129

20 Errors 131 20.1 GAUGE-VS-001 : Gauge API Not Started...... 131 20.2 GAUGE-VS-002 : Incompatible Gauge Version installed...... 131 20.3 GAUGE-VS-003 : Unable to read Gauge version...... 132

21 Welcome 133

iii iv Gauge Documentation, Release 0.9.8

Here is the recommended installation steps for all OS.

Contents 1 Gauge Documentation, Release 0.9.8

2 Contents CHAPTER 1

Windows

1.1 Using Chocolatey

You can install Gauge using Chocolatey as well. choco install gauge

If you’re upgrading to a newer version, then use the command: choco upgrade gauge

3 Gauge Documentation, Release 0.9.8

4 Chapter 1. Windows CHAPTER 2

MacOS

The following command installs Gauge. For this to work, you will need to install homebrew. If you have brew installed then all you need to run is this command; it will download and install Gauge. This requires you to be connected to the Internet. brew update brew install gauge

5 Gauge Documentation, Release 0.9.8

6 Chapter 2. MacOS CHAPTER 3

Linux

3.1 On Debian, Ubuntu

Add Gauge’s GPG key, URL to repository list and install Gauge. sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-keys 023EDB0B echo deb https://dl.bintray.com/gauge/gauge-deb stable main | sudo tee -a /etc/apt/

˓→sources.list sudo apt-get update sudo apt-get install gauge

3.2 On RHEL, Fedora, CentOS

Create file /etc/yum.repos.d/gauge-stable.repo with the following content:

[gauge-stable] name=gauge-stable baseurl=http://dl.bintray.com/gauge/gauge-rpm/gauge-stable gpgcheck=0 enabled=1

You can use this command to do it in one step: echo -e "[gauge-stable]\nname=gauge-stable\nbaseurl=http://dl.bintray.com/gauge/gauge-

˓→rpm/gauge-stable\ngpgcheck=0\nenabled=1" | sudo tee /etc/yum.repos.d/gauge-stable.

˓→repo

3.2.1 Install

Install on Fedora:

7 Gauge Documentation, Release 0.9.8

sudo dnf install gauge

Install on CentOS/RHEL: sudo yum install gauge

Having trouble with installation? Head over to our Installation FAQ’s.

8 Chapter 3. Linux CHAPTER 4

Alternate Methods

4.1 Offline Installation

4.1.1 Windows/MacOS

You can download the Gauge archive. This is a zip file. Extract it to a folder and add this to your system path. Check the Language runner to install language runner plugins.

4.1.2 Linux

Download the zip file. Choose the archive file appropriate for your installation. And run the command below to install Gauge.

unzip gauge-$VERSION-$OS.$ARCH.zip ./install.sh

Gauge can be installed at custom location by using GAUGE_PREFIX env. Example :-

GAUGE_PREFIX=my/custom/location ./install.sh

Gauge Plugins also can be installed along with gauge ( requires Internet). Set GAUGE_PLUGINS ( comma separated list of plugins) env to install plugins. Example :-

GAUGE_PLUGINS=java,xml-report ./install.sh

9 Gauge Documentation, Release 0.9.8

4.2 Nightly installation

Nightly releases are latest development snapshots of Gauge. They have the latest features being developed, but are unstable. If you want to try out Gauge nightly, do this:

4.2.1 Windows/MacOS

Based on your system requirement, you can download the Gauge archive. This is a zip file. Extract it to a folder and add this to your system path.

4.2.2 Linux

On Debian, Ubuntu

Add Gauge’s GPG key: sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-keys 023EDB0B

Run this command to add URL to repository list: echo deb https://dl.bintray.com/gauge/gauge-deb nightly main | sudo tee -a /etc/apt/

˓→sources.list

Install Gauge sudo apt-get update sudo apt-get install gauge

On RHEL, Fedora, CentOS create /etc/yum.repos.d/gauge-nightly.repo with the following content:

[gauge-nightly] name=gauge-nightly baseurl=http://dl.bintray.com/gauge/gauge-rpm/gauge-nightly gpgcheck=0 enabled=1

You can use this command to do it in one step: echo -e "[gauge-nightly]\nname=gauge-nightly\nbaseurl=http://dl.bintray.com/gauge/

˓→gauge-rpm/gauge-nightly\ngpgcheck=0\nenabled=1" | sudo tee /etc/yum.repos.d/gauge-

˓→nightly.repo

Install on Fedora: sudo dnf install gauge

Install on CentOS/RHEL: sudo yum install gauge

Having trouble with installation? Head over to our Installation FAQ’s.

10 Chapter 4. Alternate Methods CHAPTER 5

Plugins

5.1 Language runner

5.1.1C# gauge install csharp

5.1.2 Java gauge install java

5.1.3 Javascript gauge install js

5.1.4 Python gauge install python

5.1.5 Ruby gauge install ruby

One can use IDEs to create the projects and run specifications, for this example, we are using the command line options.

11 Gauge Documentation, Release 0.9.8

5.2 Reporting plugin

5.2.1 HTML Reports gauge install html-report

5.2.2 XML Reports gauge install xml-report

12 Chapter 5. Plugins CHAPTER 6

Verify your installation

You can check the version of your plugin and Gauge core by executing the following command. gauge version

If this enlists a version then you’re intallation and initialisation is has been successful. Your output will look like this:

Gauge version:

Plugins ------plugin()

You can read more about plugins here. If you have Gauge and your language runner installed, then see how you can create a Gauge project.

13 Gauge Documentation, Release 0.9.8

14 Chapter 6. Verify your installation CHAPTER 7

Uninstallation

Warning: • The Gauge folder(~/.gauge in Mac/Linux and in %APPDATA%Gauge in windows) has to be removed manually. This folder contains Gauge config, logs and plugins. • If you plan to remove the installed plugins explicitly, follow the steps in Plugins first.

7.1 Gauge

To uninstall Gauge, run the following commands:

7.1.1 Windows

Uninstallation using choco choco uninstall gauge

7.1.2OSX

Uninstallation using brew brew uninstall gauge

7.1.3 Debian, Ubuntu

Uninstallation using apt-get

15 Gauge Documentation, Release 0.9.8

sudo apt-get remove gauge

7.1.4 CentOS/RHEL

Uninstallation using yum

yum remove gauge

7.1.5 Fedora

dnf remove gauge

If Gauge is installed in custom location, remove corresponding files/directory. More on Gauge install location can be found here.

7.1.6 Alternate Methods

7.2 Plugins

Plugins can be uninstalled using the uninstall subcommand. The command is gauge uninstall Example:

gauge uninstall java

To uninstall a specific version of the plugin, use the --version flag. Example:

gauge uninstall java --version 0.3.2

16 Chapter 7. Uninstallation CHAPTER 8

Quick start

8.1 Prerequisites

• JDK 8+ / .NET framework / Ruby 2.0+ is installed • Gauge is installed. • Language runner is installed.

8.2 Creating a Project

Follow the instructions for the respective language below. On getting the message of Successfully initialized the project, one should be able to run the specifications.

Listing 8.1: C# gauge init csharp

Listing 8.2: Java gauge init java

Listing 8.3: Javascript gauge init js

Listing 8.4: Python gauge init python

17 Gauge Documentation, Release 0.9.8

Listing 8.5: Ruby gauge init ruby

Note: Refer Project Structure for files that get created for all languages.

8.3 Running the specs gauge run specs

The details of the run are displayed on the command line followed by a statistics summary.

Note: Refer Executing tests for more details.

8.4 Interpret results

The console report would give you the details of the run

Specifications: (w) executed (x) passed (y) failed (z) skipped Scenarios: (a) executed (b) passed (c) failed (d) skipped

The statistics of the scenarios indicate

Value Description (a) total number of scenarios executed. (b) total number of scenarios passed. (c) total number of scenarios failed. (d) total number of scenarios skipped.

The statistics of the specifications indicate

Value Description (w) total number specifications executed. (x) total number specifications with all scenarios passed. (y) total number specifications with atleast one scenario failed. (z) total number specifications with all scenarios skipped.

Check various supported formats for Reports.

18 Chapter 8. Quick start CHAPTER 9

Long Start

9.1 Why Gauge?

The communication breakdowns between Developers and Business Stakeholders is a common risk of software devel- opment. Gauge is an advanced automation tool that allows requirements to be written in a way that will be understood by all roles in a project and help bridge the gap. Some of the key features of Gauge that make it stand unique include: • A rich markup based on markdown • Simple, Flexible and Rich Syntax • Business Language Tests : Supports the concept of executable documentation. • Consistent Cross Platform/Language Support for writing test code. Currently supported languages. • Open Source, so it could be shared freely and improved by others as well. • A modular architecture with Plugins support. • Extensible through Plugins and Hackable. • Supports External Data Sources. • Helps you create Maintainable and Understandable test suites. • IDE Support.

9.2 Gauge Terminologies

9.2.1 Specifications (spec)

They are business layer test cases which can also act as your feature documentation. They are written in the business language. Typically a spec or specification describe a particular feature of the application under test.

19 Gauge Documentation, Release 0.9.8

• They are written in a .spec file. Gauge also supports .md file format. • The Markup for a Specification file is based on markdown syntax.

Example

Fig. 9.1: Spec

Specification Heading

A Spec must begins with a spec heading and a single specification can contain only one spec heading. It is written in

syntax of markdown. This can be in two forms:

Spec Heading ======

or

# Spec Heading

• Every spec must contain one or more Scenarios. • Every spec can be marked with labels using Tags.

20 Chapter 9. Long Start Gauge Documentation, Release 0.9.8

9.2.2 Scenarios

Each scenario represents a single flow in a particular specification. A specification must contain at least one scenario. A scenario starts after a scenario heading or a scenario name. The scenario heading is written in markdown

syntax. This can be written in 2 ways:

Scenario heading ------

or

## Scenario heading

• A scenario contains one or more steps under it. • A scenario can be tagged using tags.

Example

Configuration ======

The Admin user should be able to switch permissions for other users.

Admin Login ------* Usermustloginas"admin" * Navigatetotheconfigurationpage * Changepermissionsforuser"john"to"admin" * User"john"shouldhaveadminpermissions

9.2.3 Steps

Steps are the executable components of your specification. They are written as markdown unordered list items (bulleted points). They are written inside a specification as • Context Steps • Tear Down Steps • Steps inside a scenario or concepts Every step has an underlying code implementation for the programming language used. This is executed when the steps inside a spec are executed. See how to write Step implementations for different languages.

Example

* Loginintomyapp * Searchfor"gauge" * Searchfor"gauge-java"

9.2. Gauge Terminologies 21 Gauge Documentation, Release 0.9.8

The values written in quotes are parameters which are passed into the underlying step implementation as a language specific structure. Note: The following characters are reserved for parameters, these cannot be used in step text. • " • < • >

9.2.4 Parameters

Steps can be defined to take values as parameters so that they can be re-used with different parameter values.

* Check"product1"exists * Check"product2"exists

The underlying step implementation in code must also take the same number of parameters as passed from the step. The parameters passed into a step are of the following types:

Simple parameters

They are values passed into the steps in double quotes.

* Createa“gauge-java”project * Write“100”linespecification

Note: Renaming the parameter will not rename the usages inside the method. By design, the renamed parameter is considered as a new parameter. Therefore the usage of the old parameter(if any) has to be fixed manually to resolve the corresponding compilation issue.

Dynamic Parameters

Dynamic parameters are used as placeholder for values. Syntax: . Dynamic parameters are primarily used when referring to a table column value in Data driven execution, or while passing values to Concepts.

Example

Listing 9.1: example.cpt # A sample concept that takes a

* Andusedtheinastep.

The above concept can be invoked and a value can be passed to the concept against at the time of invocation.

* Asampleconceptthattakesa"dummyvalue"

22 Chapter 9. Long Start Gauge Documentation, Release 0.9.8

Note: Refer to this example_inline_table for illustration on how table cell values can be referred using dynamic parameters.

Table Parameters

Table parameters are used when a step is to be exucuted for multiple values. The step having a inline table parameter will be executed for each table row

Example

Create projects ======

First scenario ------

* Createthefollowingprojects |project name| username | |------|------| | Gauge java | Daredevil| | Gauge ruby | Iron Fist|

Iniline data tables can be externalized as special csv paramter

9.2.5 Special Parameters

Special parameters provide the ability to pass larger and richer data into the steps as parameters. • They are entered in angular brackets - <> in the step. • They contain 2 parts separated by a colon :

Prefix : This defines the type of special parameter. e.g. file, table. Value : This defines the value for the type of special parameter. There are two types of special parameters: 1. File 2. CSV

Special Parameter: File

These are used to read files and pass the file content as a string parameter to the underlying steps. Syntax : where [value] is the path to the file.

Note: [value] can be an absolute or relative path. Relative paths are resolved relative to GAUGE_PROJECT_ROOT.

9.2. Gauge Terminologies 23 Gauge Documentation, Release 0.9.8

* Verifyemailtextis * Checkifisvisible

The path to the file can be the relative path from the Gauge project or an absolute path to the file.

Special Parameter: CSV

Tables are used to pass table value into steps read from an external CSV file. The parameter text in the step contains a prefix table and the path to the csv file. Syntax : where [value] is the path to the csv file.

Note: [value] can be an absolute or relative path. Relative paths are resolved relative to GAUGE_PROJECT_ROOT.

* Stepthattakesatable * Checkifthefollowingusersexist

Sample csv file:

Id,Name 1,The Way to Go On 2,Ivo Jay Balbaert

The first row is considered as table header. Following rows are considered as the row values.

Data Table values in inline tables

Dynamic values from the data table can also be referred in table parameters passed into steps

Example

Create projects ======

|id| name | |--|------| |1 | john | |2 | mike |

First scenario ------

* Createthefollowingprojects |project name| username | |------|------| | Gauge java | | | Gauge ruby | |

In the above example the table parameter uses a dynamic value from the data table.

24 Chapter 9. Long Start Gauge Documentation, Release 0.9.8

9.2.6 Tags

Tags are used to associate labels with specifications or scenarios. Tags are written as comma separated values in the spec with a prefix Tags: . • Both scenarios and specifications can be separately tagged • Only one set of tags can be added to a single specification or scenario. They help in filtering specs or scenarios based on tags used.

Example

Both the Login specification and the scenario Successful login scenario have tags in the below example.

Login specification ======Tags: login, admin, user-abc

Successful login scenario ------Tags: login-success, admin

A tag applied to a spec automatically applies to a scenario.

9.2.7 Concepts

Concepts provide the ability to combine re-usable logical groups of steps into a single unit. It provides a higher level abstraction of a business intent by combining steps. They are defined in .cpt format files in the specs directory in the project. They can be inside nested directories inside the specs directory. • Concepts are used inside spec just like any other step. The appropriate parameters are passed to them. • On execution all the steps under the concepts are executed in the defined order. Note: A single .cpt file can contain multiple concept definitions.

Defining a concept

Create a .cpt file under specs directory with the concept definition. The concept definition contains the 2 parts: • Concept header • Steps

Concept header

The concept header defines the name of the concept and the parameters that it takes. It is written in the markdown ‘‘H1‘‘ format. • All parameters are defined in angular brackets < >.

9.2. Gauge Terminologies 25 Gauge Documentation, Release 0.9.8

• A concept definition must have a concept header.

# Concept name with and

Steps

The concept header is followed by the steps that are used inside the concept. They are defined in the usual steps structure. • All the parameters used from the concept header will be in < > brackets. • Fixed static parameter values are written in quotes "". • Other concepts can also be called inside the concept definition.

# Login as user and create project

* Loginasuserand"password" * Navigatetoprojectpage * Createaproject

In the example above: • The first line is the concept header • The following 3 steps are abstracted into the concept The concept above can now be used in any spec as shown below

Login specification ======

Successful login scenario ------* Loginasuser"john"andcreateproject"Gaugejava"

9.2.8 Contexts

Contexts or Context steps are steps defined in a spec before any scenario. They allow you to specify a set of conditions that are necessary for executing scenarios in a spec. Context steps can be used to set up data before running scenarios. They can also perform a setup or tear down function. • Any regular steps can be used as a context. • Contexts are executed before every scenario in the spec.

Delete project ======These are context steps

* Userisloggedinas"mike" * Navigatetotheprojectpage

Deletesingleproject ------* Deletethe"example"project * Ensure"example"projecthasbeendeleted

26 Chapter 9. Long Start Gauge Documentation, Release 0.9.8

Deletemultipleprojects ------* Deletealltheprojectsinthelist * Ensureprojectlistisempty

In the above example spec the context steps are User is logged in as Mike and Navigate to the project page, they are defined before any scenario. These steps are executed before the execution of each scenario Delete single project and Delete multiple projects. The spec execution flow would be: 1. Context steps execution 2. Delete single project scenario execution 3. Context steps execution 4. Delete multiple projects scenario execution

9.2.9 Tear Down Steps

Tear Down Steps are the steps defined in a spec after the last scenario. They allow you to specify a set of clean-up steps after every execution of scenario in a spec. They are used to perform a tear down function. • Any regular steps can be used as a tear down step. • Tear down steps are executed after every scenario in the spec.

Syntax

___: Three or more consecutive underscores will indicate the start of tear down. Steps that are written in tear down(after three or more consecutive underscores) will be considered as tear down steps.

___ * Teardownstep1 * Teardownstep2 * Teardownstep3

Example

Delete project ======

* Signupforuser"mike" * Loginas"mike"

Deletesingleproject ------* Deletethe"example"project * Ensure"example"projecthasbeendeleted

Deletemultipleprojects ------

9.2. Gauge Terminologies 27 Gauge Documentation, Release 0.9.8

* Deletealltheprojectsinthelist * Ensureprojectlistisempty

______Theseareteardownsteps

* Logoutuser"mike" * Deleteuser"mike"

In the above example spec, the tear down steps are Logout user "mike" and Delete user "mike", they are defined after three or more consecutive underscores. The spec execution flow would be: 1. Context steps execution 2. Delete single project scenario execution 3. Tear down steps execution 4. Context steps execution 5. Delete multiple projects scenario execution 6. Tear down steps execution

28 Chapter 9. Long Start CHAPTER 10

Using Gauge

Gauge is a first class command line tool. This means that you can operate entirely from the command line. Or, if you prefer to use an IDE then Gauge also has excellent integration with multiple IDEs.

10.1 Command Line Interface

Gauge has first-class command line support. With gauge installed, list the subcommands/flags supported by running. gauge

The command-line interface works across platforms. On GNU/Linux and OSX, you can use any terminal. On Win- dows, you can use cmd or Powershell.

10.1.1 Help

Since subcommands/flags get added/deprecated with versions, it is recommended to get this reference via gauge itself. gauge help

10.1.2 Creating a project

To create or initialize a Gauge project use run gauge init