Cucumber: Test driven development basics

in #test8 years ago

Cucumber

A need is what starts an effort, this effort usually is placed in a period of time which is commonly called project. Most of the projects starts documenting the needs in no specific format and sometimes lacking the details that are required for a development team to put all the pieces together and create the software the client really wanted to fulfill that specific need. The main problem in most teams and projects is the lack of communication. Usually clients will ask development teams to do something they though they wanted at a time. When the development team think they understand what the client wanted the development process starts. Usually the documentation is outdated and might need to be reviewed with the client, on the other hand development is performed in parallel, in some other cases it is done in different stages or phases. The resulting product might be out of sync with the client needs, expectations and not completely make a client happy.

Cucumber helps to reduce the lack of communication providing an agile and fast collaboration between the client and the development team. Using the documentation to provide guidance to the development team and testing every aspect of if as adds different pieces. It is also written in a common language that both sides can easily understand reducing the misunderstandings and helping to be sync for both the documented needs, tests and software.

I want to introduce you to the cucumber world by guiding you in the installation and first steps into this amazing tool.

Cucumber itself should be the same in any programming language, it uses Gherkin Syntax as way to provide an standard and also it is implemented in many flavors. I'm going to use the ruby one.

Bundle

gem install bundle
Bundle will help you manage the gems within the cucumber folder. It is very used in the ruby world and you might note that if you are building something with Ruby on Rails cucumber is fully integrated and supported.
bundle init
This will start a Gemfile which will managed the gems, versions, dependencies. It is not need for this small project but highly recommended.

Selection_047.png

bundle add cucumber
This is the way to add gems to the file for management.

Selection_048.png

bundle install
This is the action you will perform after cloning or pulling a new Ruby project.

Selection_049.png

Cucumber

We now have a running cucumber enviroment. If you try to run cucumber you will see that there is not default cucumber structure and you can create one with cucumber --init

Selection_050.png

As we are doing TDD we will let cucumber guide us in the whole process.

Selection_051.png

Selection_052.png

As you can see there are 0 scenarios to test. 0 steps to execute.

Now let's create our feature file but what is a feature anyway?
Think of a feature of a working piece, I know the definition still lacks depth but think of a car, you will need basic features to have a car like:

  • tires
  • structure
  • seats
  • engine
    But what ever you are thinking of might not be the same as the client thought, so a feature pretty much is the thing or piece of thing that will help us fulfill whatever need the client has. But once again you need to document what the client need.

To be able to continue in this journey I will be working on a product that will help me track my coins collection and will allow me to get more information about each coin.

I would like to have something to enter few words and upload few pictures of my coin.
I would like some sort of fetch data that will look into more details of that coin.
Every coin will have some data elements like:

  • country: USA
  • value: 10 cents
  • metal(s): gold
  • market value: $300 USD
  • Year: 1835

Selection_053.png

Selection_054.png

Stay tuned, in the next post I start adding more details about this project.

Sort:  

Nice read. I leave an upvote for this article thumbsup

You just planted 0.15 tree(s)!


Thanks to @raserrano

We have planted already 3791.12 trees
out of 1,000,000


Let's save and restore Abongphen Highland Forest
in Cameroonian village Kedjom-Keku!
Plant trees with @treeplanter and get paid for it!
My Steem Power = 19227.98
Thanks a lot!
@martin.mikes coordinator of @kedjom-keku
treeplantermessage_ok.png

Congratulations @raserrano! You have received a vote as part of @raserrano donation to this project.
I will be able to help more #minnows

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.078
BTC 60993.71
ETH 1618.63
USDT 1.00
SBD 0.42