Setup Gauge
Requirement
- Node.js version >= 10.16.3 (LTS). Follow the instruction in the link below to install Node.js.
- Yarn & Gauge
- Open a new shell.
- Install Yarn with the following command:
sudo npm install -g yarn- Install Gauge as a global tool with the following command.
sudo npm install -g @getgauge/cli- It will take a several minutes since installing Gauge needs Chromium.
- Gauge works cross platforms but for using Linux, you need to use sudo when install it.
Verify all requirement
- Open a new shell and execute the following commands:
yarn -vgauge -v
- You should get versions of Yarn and Gauge without any errors.
Create a new Gauge project with TypeScript template
- Open a new shell.
- Create a new folder for a Gauge project and initialize the project with TypeScript template.
mkdir gauge-examplecd gauge-examplegauge init ts
- Optionally, you can change a folder name (project name) to any name that you want.
- Tip use
gauge init js
to create a Gauge project with JavaScript template. - Install all Node.js packages with yarn.
yarn install
Open and update the project with VS Code
- Open the project folder with VS Code
code .
- Install Gauge extension for VS Code
- In VS Code, click extension button on the left-hand side of the screen, search and install "Gauge" extension.
- More information for Gauge extension https://marketplace.visualstudio.com/items?itemName=getgauge.gauge
- Optionally, add
.editorconfig
file at the root of the project with the following content:
# EditorConfig is awesome: https://EditorConfig.org# top-most EditorConfig fileroot = true[*]# Unix-style newlines with a newline ending every fileend_of_line = lfindent_style = spaceindent_size = 2insert_final_newline = true
- Optionally, you can add
"editor.codeLens": true
to.vscode/settings.json
to make sure code lens is always enable.- Gauge extension uses code lens for showing
Run Scenario|Debug Scenario
option. - Here is the example content of
.vscode/settings.json
{"files.associations": {"*.spec": "gauge","*.cpt": "gauge"},"editor.codeLens": true,} - Gauge extension uses code lens for showing
Run the project from Ru Scenario option
- Open
/specs/example.spec
file and you will findRun Scenario
option aboveDisplay number of items
message Display number of items
is a test scenario.- Click
Run Scenario
and a browser will be launched a todo app. - After a test has finished, you will get a successful result in the output window.
- You can view a test report from a link in the output window.
Run project from the command line
- Open package.json at the root of the project and add the following code
"scripts": {"test": "gauge run specs"}
- Open VS integrated terminal.
- Run all tests in the project with the following command:
yarn test
- Here is the test result in a terminal
$ gauge run specs# Getting Started with Gauge## Display number of items ✔ ✔ ✔ ✔ ✔ ✔## Must list only active tasks ✔ ✔ ✔ ✔ ✔ ✔ ✔Successfully generated html-report to => /home/aaron/projects/gauge-example/reports/html-report/index.htmlSpecifications: 1 executed 1 passed 0 failed 0 skippedScenarios: 2 executed 2 passed 0 failed 0 skippedTotal time taken: 3.659s
Loading comments...