Giter Club home page Giter Club logo

cucumber_tutorial's Introduction

Cucumber tutorial

Cucumber is a BDD testing framework, which uses a DSL to describe wanted behaviour and can use ruby to implement the tests.

Installation

Linux

sudo apt install ruby-dev # to build cucumber
sudo gem install cucumber # apt's cucumber is v2.4, gem's is v5.2
sudo gem install rspec-expectations # makes expect() available

macOS

brew install ruby-build rbenv
rbenv install 2.7.2 # ruby 3.0 does not build cucumber yet
~/.rbenv/versions/2.7.2/bin/gem install cucumber
~/.rbenv/versions/2.7.2/bin/gem install rspec-expectations

Windows

scoop install ruby
gem install cucumber
gem install rspec-expectations

When cucumber complains about missing ANSICON, put export ANSICON=1 into your .bashrc.

Dir structure

.
├── cucumber.yml
├── features
│   ├── step_definitions
│   │   └── definitions.rb
│   └── tests.feature
├── README.md
└── .vscode
    └── launch.json

Running

After you have installed cucumber, you can add a test description into the features folder and run cucumber from the command line.

VS Code

Debugging

To debug the tests with VSCode, install ruby-debug-ide

sudo gem install ruby-debug-ide

Then put this launch.json into the .vscode folder of your working directory

{
    "configurations": [
        {
            "name": "Cucumber",
            "type": "Ruby",
            "request": "launch",
            "program": "/usr/local/bin/cucumber"
        }
    ]
}

Now you can set breakpoints in the definitions.rb and VS Code stops there if run from it.

Formatting

To auto-format the definitions.rb, install rufo and the rufo plugin for VS Code

sudo gem install rufo

Silenting cucumber

To remove the ad in the footer, add a cucumber.yml with

default: --publish-quiet

cucumber_tutorial's People

Contributors

elsamuko avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.