cucumber-iii

15
1 Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential. Behavior Driven Development CUCUMBER Chaitanya Kumar Reddy(338057) 29/09/2015

Upload: chaitanya-kumar-reddy

Post on 19-Jan-2017

29 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cucumber-III

1Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Behavior Driven Development

CUCUMBER

Chaitanya Kumar Reddy(338057) – 29/09/2015

Page 2: Cucumber-III

2Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Introduction

Behavior Driven Development

Use vs. Don’t Use

Cucumber Feature File

Step Definition

References

Agenda

Page 3: Cucumber-III

3Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Introduction

Cucumber is a tool based on BDD (Behavior Driven Development) framework.

Cucumber is used to write acceptance tests for a web application.

It allows the developer to develop the test cases in a very easy way, that everyone can understand.

Cucumber was implemented in Ruby and later extended to Java.

Cucumber can be used along with Selenium.

Cucumber Supports many other languages like Perl, PHP, Python, .Net etc.

Page 4: Cucumber-III

4Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Behavior Driven Development (BDD)

Behavior-driven development is an agile software development technique that encourages collaboration between developers, QA and non-technical participants in a software project. 

Behavior Driven Development is emerged from Test Driven Development.

TDD BDD

Page 5: Cucumber-III

5Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Use vs. Don’t Use

Cucumber is useful: Separation of examples and automation Possess structure but not too much Pressure to grow a ubiquitous language Just enough syntax

Cucumber is not useful: Small set of tests Too much overhead Only developers will look at the tests Working with Regular expressions

Page 6: Cucumber-III

6Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Cucumber Feature File

Every cucumber project consists of a directory named features.

This directory contains feature files with extension “.feature”

Feature file contains following components:

Feature Scenario/Scenario Outline

• Given• When • Then • And• But

Page 7: Cucumber-III

7Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Cucumber Feature File ..cont.

Feature: This will describe about the current feature file.

Scenario: Describes the steps and expected output for the test case.

- Below is the example for scenario:

Page 8: Cucumber-III

8Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Cucumber Feature File ..cont.

Scenario Outline: A scenario that is executed for multiple sets of data. Below is the example for defining Scenario Outline.

Page 9: Cucumber-III

9Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Cucumber Feature File ..cont.

Given: Specifies the context of the test to be executed and puts the system in known state.

When: Specifies the key action to be performed.

Then: Observes the output.

And/But: If there are several ‘Given’s, ‘When’s and ‘Then’s. We can use And/But to replace some of them.

Page 10: Cucumber-III

10Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Step Definition

Every step in the feature file will be having a step definition.

Step Definition will have the code to perform the actions.

Step Definition will have the string that matches the string in feature file.

-- feature

Page 11: Cucumber-III

11Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Below are the step definitions for the above feature.

Step Definition ..cont.

Page 12: Cucumber-III

12Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Step Definition ..cont.

In step definitions we will write selenium code to automate the test cases.

Page 13: Cucumber-III

13Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

References

https://github.com/cucumber/

Page 14: Cucumber-III

14Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.

Disclaimer Tech Mahindra Limited, herein referred to as TechM provide a wide array of presentations and reports, with the contributions of various professionals. These presentations and reports are for informational purposes and private circulation only and do not constitute an offer to buy or sell any securities mentioned therein. They do not purport to be a complete description of the markets conditions or developments referred to in the material. While utmost care has been taken in preparing the above, we claim no responsibility for their accuracy. We shall not be liable for any direct or indirect losses arising from the use thereof and the viewers are requested to use the information contained herein at their own risk. These presentations and reports should not be reproduced, re-circulated, published in any media, website or otherwise, in any form or manner, in part or as a whole, without the express consent in writing of TechM or its subsidiaries. Any unauthorized use, disclosure or public dissemination of information contained herein is prohibited. Unless specifically noted, TechM is not responsible for the content of these presentations and/or the opinions of the presenters. Individual situations and local practices and standards may vary, so viewers and others utilizing information contained within a presentation are free to adopt differing standards and approaches as they see fit. You may not repackage or sell the presentation. Products and names mentioned in materials or presentations are the property of their respective owners and the mention of them does not constitute an endorsement by TechM. Information contained in a presentation hosted or promoted by TechM is provided “as is” without warranty of any kind, either expressed or implied, including any warranty of merchantability or fitness for a particular purpose. TechM assumes no liability or responsibility for the contents of a presentation or the opinions expressed by the presenters. All expressions of opinion are subject to change without notice.

Thank [email protected]

Page 15: Cucumber-III

15Copyright © 2014. All Rights Reserved. l Tech Mahindra Confidential.