You are on page 1of 12

Testing types

ways to test out application


manual testing
automation testing
TDD
BDD
Cucumber
Gherkin
Selenium
Webdriver

9 days
Agenda Today's session:
-----------------------
Software Testing:
-----------------
- is the process of evaluating a system to find
bugs
- is performed to check if the system satisfies it's
specified requirements
- completeness, usability, performance and other
functional and non-functional attributes
- validation, verification

- why testing
SDLC ( Software Development Life Cycle)

- Waterfall Model
- Requirements analysis
- planning
- implementing
- testing
- integration
- production

- to avoid defects
- result into less cost and resource
utilization

who does testing:


------------------
- developer: unit testing of the software
- tester: Testers are the face of software testing.
- functionality, usability and performance
- Test Managers/Lead/Architects: test strategy
and test plan
- client: UAT (User Acceptance Testing)
can work in real world
Defect:
-------
System.out.println("this is a testing");

- A defect or bug is an error


P0 - high priority
P3 - low priority
Defect Template:
----------------
defect id
summary
Description
Build Version
Priority P0 - urgency
Reported By
Reported on
Assigned To
Current Status:
Defect LifeCycle:
-----------------
new -> assigned -> open -> In Test -> Verified
-> Closed

Junit:
------
- to test method functionality
- using normal java project
- using maven tool
- jars
- junit
- hamcrest-core
- using annotation
- @Test
- Before
- BeforeClass
- After
- AfterClass
- Ignore

- Write a Java Program to count No Of Vowels


in a given String

- create a java class CountVowels


- add a method countVowelsInString(String s) {
// write code here
}

- Testing levels:
-----------------
- functional testing
- each function of that application
- Unit Testing
- Integration Testing
- Smoke Testing
- Sanity Testing
- System Testing
- UAT

- Non Functional Testing


- Performance Testing: Speed, Scalability,
Stability and Reliability
- Load Testing
- Security Testing

- Testing Methods:
-------------------
- Black Box Testing
- also known as functional testing
without knowing the intrnal codes and
structure of the program

- White Box Testing


- internal codes and structure of a program
is known to the tester

- Gray Box Testing


- combination of Black box and white box

Summary:
---------
- s/w testing
- why testing is required
- who does testing
- defect
- defect life cycle
- Steps in manual testing process
- created and executed test cases written using
junit
- Testing levels
- Testing methods
black box, white box, gray box

Day - 2:
--------
- TDD
- BDD
- Cucumber
- Gherkin
- Set up cucumber with Eclipse

TDD ( Test Driven Development ):


---------------------------------
- is an iterative development process.
- Each iteration starts with a set of tests.
- these tests are supposed to fail during the
start of iteration as there will be no application
code
- in the next phase of iteration application
code is written to pass all the tests

BDD ( Behaviour Driven Development):


-------------------------------------
- is an extension of TDD
- Like TDD, In BDD also we write tests first and
add application code
- Tests are written in plain descriptive English
type grammar
- Tests are explained as behaviour of application
and are more user focused

Features of BDD:
----------------
- collaboration between business stakeholders,
business analysts, QA team and developers

- ubiquitous language, it is easy to describe


- BDD frameworks such as Cucumber or JBehave
- act as a bridge between business and
technical language

- BDD Tools
Cucumber
SpecFlow

- What is cucumber
- Cucumber is a testing framework which supports
BDD.
- define application behaviour in meaningful
english text using a simple grammar defined by
a language called Gherkin
- Gherkin
- Cucumber is written in Ruby.
- it can be used to test code written in Ruby or
other languages like java, c#, python etc.

- Why BDD:
----------
- assume there is a requirement from a client for
an e-commerce website to increase the sales of the
product.

Architect:
Requierment analysis
planning

developer:
implementing
Tester:
testing

1. client delivering his idea to architect

2. architect to delivering recieved requirement


to team manager

3. manager delivering requirements to team lead


4. team lead passing this requirements to developer

Wrong perception:

Example of a Cucumber
----------------------
Feature: Sign up
Scenario: Successful sign up
Given I have to sign up
When I sign up with valid details
Then I should recieve a confirmation mail

feature file

Gherkin:
--------
- search box
- search for product iphone x
- will return results contains all products

- what should be search results if user searches


invalid product

iphone

ione

Gherkin was created

- Gherkin is a simple, lightweight and


structured language
- it follows some syntax
Feature: login feature
Scenario: login with valid username and pass
when I click on login button
then able to login successfully

- Gherkin contains a set of keywords

- key points
* the test is written in plain english which is
common to all the domains

* This test is structured that makes it capable of


being read in an automated way.

* Gherkin contains a set of keywords

Cucumer helps improve communication

Cucumber is a tool used to run automated acceptance


tests created in BDD format.

Cucumber helps improve communication between


technical and non-technical members in the same
project

Cucumber is an automated acceptance testing tool

All testers can take part in automation test


with Cucumber BDD

Set up Cucumber with Eclipse

- Java
- Eclipse or STS
-

Cucumber Jars:
--------------
1. cucumber-core
2. cucumber-java
3. cucumber-junit
4. cucumber-jvm-deps
5. cucumber-reporting
6. gherkin
7. junit
8. mockito-all
9. cobertura

1. download cucumber jars from online maven repo


2. download cucumber jars from oss.sonatype.org
3. download cucumber jars from maven dependencies

bddtestingapp
folder name: Feature

calculator.feature

cucumber plugin is required

STS or Eclipse:
---------------
- cucumber plugin

Maven Project:
--------------
- dependencies to added to pom.xml

- Create Feature folder


- create feature file in Feature folder
- run feature as cucumber feature

Summary:
--------
- TDD
- BDD
- Why BDD
- Cucumber
- Gherkin
- Set up cucumber with STS or Eclipse

cucumber is a tool that supports BDD

cucumber reads executable specifications

these specifications consists of multiple


scenarios

each scenario is a list of steps

Feature:
Scenario:
Given
Then
Gherkin:
---------
Gherkin is a simple, lightweight and structured
language

- Unambiguous executable specification


- Automated testing using cucumber
- document how the system actually behaves

we need the following:


-----------------------
- cucumber plugin for elispse or sts (one time)

- create maven project


- add dependencies to pom.xml
- right click project then select run as
click mvn clean
- create folder called Feature
- create feature file in Feature folder

Day - 3:
---------
- cucumber feature file
- Junit Test Runner class
- Gherkin keywords
- Step definitions
- Cucumber options

- Cucumber feature file:


------------------------
- A feature file is an entry point to the cucumber
tests
- This is a file where you will describe your tests
in descriptive language(English).
- it is an essential part of cucumber
- features/Features
- file extension should be .feature
login.feature
signup.feature
calculator.feature
search.feature

- Feature: Facebook login


Scenario: Login with valid credentials
Given User is on login page
When user enters valid username and password
Then message displayed login successfully

- keywords:
------------
- Feature: defines what feature you will be testing
- Scenario: title of the test
- Given: tells the pre-condition of the test
- When: additional condtions
- Then: post condition expected outcome

Gherkin:
---------
- A language above is called gherkin
- it implements the principles of BRDSL
Business Readable Domain Specific Language

- run cucubmer test either using junit or testng

Junit Test Runner Class:


-------------------------
- Create a new class and name it as TestRunner

Step Definition File:


----------------------
- A Step definition file is a small piece of code
with a pettern attached to it or

- Step definition is a java method in a class with


annotation.

- this pattern is used to link the step definition


to all the matching steps and the code

- cucumber feature file


- step definition file
- test runner

- create maven project onlinestore


- add deps to pom.xml
- crete a feature file signup.feature
- stepdefinitions
- test runner

- syntax for comments:


#
Summary:
========
- Cucumber feature file
- Step definition
- Test Runner
- gherkin keywords
Feature, Scenario, Given, When, Then
- add comments using #

Day - 4:
--------
- Gherkin keywords
- Cucumber options
- Data tables
- Cucumber Hooks

Gherkin Keywords:
------------------
Feature:
---------
- Each Gherkin file begins with a Feature keyword.
- Feature defines the logic test functionality you
will test in this feature
- If you are testing payment gateway your
Feature will become Payment Gateway
Feature: Payment Gateway
- idea of having a feature file is to put down
a summary of what you will be testing
Feature: Login Action Test
or
Feature: Login Action Test
Description: This feature will test a login
and logout functionality

or
Feature: Login Action Test
This feature will test a login and logout
functionality

Background:
-----------
- Bakcground keyword is used to define steps which
are common to all the tests in a feature file.
- Navigate to Home page
- Click on the login link
- enter username and password
- click on sumbit

Feature: Add to cart


Background: User is logged In
Scenario: Search a product and add the
products to the cart
Given User searched for macbook
When add the macbook that appears in search
result to cart
Then cart should display 1 item

Feature: Sign Up and sign in


Background: Application url

Scenario: signup
given signup page
when user enters user and pass
Then registered

Scenario: login
given: login page
when user enters user and pass
then user logged in successfully

Scenario:
---------
each feature file will contain some number of tests
to test the feature.
Each test is called a scenario
- is equivalent to a test in our regular dev
process
- can break this into 3 parts
1. pre-condition (Given)
2. Test step excution (When)
3. Verification of the output with
expected result

- Given:
--------
- Given defines a pre-condition test.
Given User is on Home Page

- When
-------
- defines test action that will be executed

- Then:
-------
- defines the outcome of previous steps
Feature: Login
Scenario: Login with valid credentials
Given User is on home page
When user navigate to login page
And user enters username and password
And user has to be validate
Then message displayed successfully

And:
----
- is used to add conditions to youre steps

But:
----
Feature: Login
Scenario: Login with valid credentials
Given User is on home page
When user navigate to login page
And user enters username and password
And user has to be validate
But the user is invalid
Then message displayed wrong username & pass

*:
-
Feature: Login
Scenario: Login with valid credentials
* User is on home page
* user navigate to login page
* user enters username and password
* user has to be validate
* the user is invalid
* message displayed wrong username & pass

Gherkin Keywords:
==================
- Feature
- Scenario
- Given
- When
- And
- But
- Then
- *

#- to put comments in feature file


| - (pipe operator) used define data table in
feature
""" - documenation (doc strings)

"""
cucumber feature file contains
one or more scenarios
"""

Cucumber options:
------------------
- In layman language @CucumberOptions are like
property file or settings for your test

- features: path of feature files


- glue: path of step definition files
- dryRun: default value: false
true: checks if all the steps have the
step definition
- tags: what tags in the feature files
should be executed (instruct)
- monochrome:
default value: false
monochrome = true
- display the console output in readable way
- format: set
what all report formatters to use

Feature: Calculator
Scenario: Addition to two values
Given two values
When I add two values
Then result is sum of two values

Scenario Outline is used to run same scenario


for 2 or more different set of test data

Summary:
--------
- Gherkin keywords
- Cucumber Options
- Data tables
- scenario outline with examples keyword
- scenario witout examples keyword
- passing data to the scenario
- maps in cucumber
passing map as data to the scenario
without examples keyword

You might also like