Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Review of Cucumber Testing Framework
1. Review of CucumberReview of Cucumber
Presented byPresented by
Jabeen Shazia IqbalJabeen Shazia Iqbal
CWID: 899287056CWID: 899287056
June 19, 2016June 19, 2016
2. Unit TestingUnit Testing
The smallest testable part is called Unit, which has one or few inputs andThe smallest testable part is called Unit, which has one or few inputs and
mostly has single output.mostly has single output.
It is required to validate these units whether the each unit of the softwareIt is required to validate these units whether the each unit of the software
performs as designed, Individual units/components of a software are testedperforms as designed, Individual units/components of a software are tested
Perform White Box Testing.Perform White Box Testing.
Developers perform this unit testing, but in some cases it may beDevelopers perform this unit testing, but in some cases it may be
performed by the independent software testers as well.performed by the independent software testers as well.
The main purpose of this unit testing is to identify failures in the logicThe main purpose of this unit testing is to identify failures in the logic
and/or algorithms that helps to improve the quality of the code.and/or algorithms that helps to improve the quality of the code.
3. MotivationMotivation
→ To change or maintain the code, we would need moreTo change or maintain the code, we would need more
confidenceconfidence
→ Codes are often reusable.Codes are often reusable.
→ To make the development of the software fast.To make the development of the software fast.
4. Cont..Cont..
→ The cost of fixing of the defects detected in the Unit TestingThe cost of fixing of the defects detected in the Unit Testing
would be less comparative to the cost of fixing of defectswould be less comparative to the cost of fixing of defects
detected in another test such as system or acceptance testing.detected in another test such as system or acceptance testing.
→ Debugging becomes easy. When a Unit test fails, only theDebugging becomes easy. When a Unit test fails, only the
latest changes need to be debugged.latest changes need to be debugged.
→ Code after performing the unit testing is more reliable.Code after performing the unit testing is more reliable.
5. To perform Unit TestingTo perform Unit Testing
1. Create a Test Plan1. Create a Test Plan -- Test Plan is the document which has theTest Plan is the document which has the
information about how the test will be performed, things to be tested, roles,information about how the test will be performed, things to be tested, roles,
responsibilities, test environment, activities involved etc.responsibilities, test environment, activities involved etc.
2. Create Test Cases and Test Data2. Create Test Cases and Test Data -- Test case and Test Data documentsTest case and Test Data documents
are prepared using the sample format the Organization is adopting. Testare prepared using the sample format the Organization is adopting. Test
Cases document will involve information such as Test case description,Cases document will involve information such as Test case description,
expected result, actual result, pass/fail, etc… Test Data document willexpected result, actual result, pass/fail, etc… Test Data document will
involve information such as the inputs required to be created for theinvolve information such as the inputs required to be created for the
specific function and condition, to perform the unit testing.specific function and condition, to perform the unit testing.
3. Write Test Scripts3. Write Test Scripts – If we going to automate the Test Cases, then– If we going to automate the Test Cases, then
writing Test Scripts may results in saving time that is requited for testingwriting Test Scripts may results in saving time that is requited for testing
6. Cont..Cont..
4.Write the actual code4.Write the actual code- Code is developed in such a way that these test- Code is developed in such a way that these test
cases gets pass when executed.cases gets pass when executed.
5.Once the code is ready to execute the test cases5.Once the code is ready to execute the test cases – Execution of the– Execution of the
Test Cases, written in the above 2nd step, will be performed on the writtenTest Cases, written in the above 2nd step, will be performed on the written
code.code.
6.Fix the bugs if any and re test the code6.Fix the bugs if any and re test the code - Result of the execution of- Result of the execution of
code will be captured. If the no error pops up, the codes are ready to go. Ifcode will be captured. If the no error pops up, the codes are ready to go. If
not, alter the code in such a way to remove the error/bug occurred duringnot, alter the code in such a way to remove the error/bug occurred during
execution. Once the code is updated, rerun the test cases on the updatedexecution. Once the code is updated, rerun the test cases on the updated
code to validate whether the result turns out to be pass.code to validate whether the result turns out to be pass.
7.Repeat the test cycle until the “unit” is free of all bugs7.Repeat the test cycle until the “unit” is free of all bugs - Tester need to- Tester need to
keep updating the code, if the error/bugs appears until there is no bugs inkeep updating the code, if the error/bugs appears until there is no bugs in
that specific module.that specific module.
8. CucumberCucumber
A testing framework driven by plain English textA testing framework driven by plain English text
It supports all programming languageIt supports all programming language
It behaves as a documentation and automatedIt behaves as a documentation and automated
teststests
9. Cucumber FormatCucumber Format
GherkinGherkin is the format for Cucumber Specifications. Technically speaking it is ais the format for Cucumber Specifications. Technically speaking it is a
small computer language with a well-defined syntax,small computer language with a well-defined syntax,
Feature:Feature: name of the feature goes herename of the feature goes here
Description:Description: Write the description of this feature in this field.Write the description of this feature in this field.
Scenario:Scenario: Acceptance criteria scenario goes here.Acceptance criteria scenario goes here.
GivenGiven
WhenWhen
AndAnd
ThenThen
10. Procedure to use CucumberProcedure to use Cucumber
Pre-requisite:Pre-requisite:
RubyMine JetBrains – 30 Trial version is availableRubyMine JetBrains – 30 Trial version is available
Install CucumberInstall Cucumber
Steps to play with cucumberSteps to play with cucumber
Step 01: Open the RubyMine JetBrains.Step 01: Open the RubyMine JetBrains.
Step 02: Create folder as “feature” and create two filesStep 02: Create folder as “feature” and create two files
FilenameForGherkinScripts.featureFilenameForGherkinScripts.feature
Step_definationStep_defination
Step 03: Write the Gherkin Scripts in the .feature fileStep 03: Write the Gherkin Scripts in the .feature file
Step 04: Run the .feature fileStep 04: Run the .feature file
Step 05: Check the errors throwedStep 05: Check the errors throwed
Step 06: Paste the Gherkin Scripts and Write the actual Ruby Code inStep 06: Paste the Gherkin Scripts and Write the actual Ruby Code in
the Step definitions filethe Step definitions file
Step 07: Again run the .feature file, repeat the steps 05 and 07 until allStep 07: Again run the .feature file, repeat the steps 05 and 07 until all
errors the are cleared out.errors the are cleared out.
15. Procedure Cont..Procedure Cont..
Run cucumber scripts again.Run cucumber scripts again.
All steps, and therefore the entire scenarioAll steps, and therefore the entire scenario
should now be marked as “passed”should now be marked as “passed”
16. Merits of CucumberMerits of Cucumber
This unit testing tool is the friendly and understandable by non technical userThis unit testing tool is the friendly and understandable by non technical user
The Given-When-Then syntax of Cucumber scenarios imposes some structureThe Given-When-Then syntax of Cucumber scenarios imposes some structure
on scenarios while leaving plenty of room for teams to grow their ownon scenarios while leaving plenty of room for teams to grow their own
language to describe their systemlanguage to describe their system
The style of writing test allows to reuse the gherkins scriptsThe style of writing test allows to reuse the gherkins scripts
Predictability and improve the confidence among testers and developersPredictability and improve the confidence among testers and developers
The separation of the three level of feature in the gherkin scripts makes itThe separation of the three level of feature in the gherkin scripts makes it
easier to reuse any part of the codeeasier to reuse any part of the code
As we know that interaction of Business and IT is not quite good. ThisAs we know that interaction of Business and IT is not quite good. This
cucumber makes the bond stronger between them by mentioning thecucumber makes the bond stronger between them by mentioning the
customer’s executable specification to the team, helping them to be aware ofcustomer’s executable specification to the team, helping them to be aware of
the business goals in mind at all timesthe business goals in mind at all times
17. Cont..Cont..
Automation in cucumber lets the specification updated in the gherkinsAutomation in cucumber lets the specification updated in the gherkins
scriptsscripts
Automation leads to save the team from costly regressionAutomation leads to save the team from costly regression
Even the reuse of code is possible, since we write the features inEven the reuse of code is possible, since we write the features in
separateseparate
Supports other language as well beyond Ruby like Java, Scala, GroovySupports other language as well beyond Ruby like Java, Scala, Groovy
etc.etc.
Quick and easy set up and executionsQuick and easy set up and executions
Cucumber focuses on end-user experienceCucumber focuses on end-user experience
Efficient tool for testingEfficient tool for testing
2.
18. Demerits of CucumberDemerits of Cucumber
Extra code for converting the textual specification to Ruby codeExtra code for converting the textual specification to Ruby code
OneOne more layer between test description and the code (you need tomore layer between test description and the code (you need to
make sure the code really matches the description)make sure the code really matches the description)
Cucumber supports only web environmentCucumber supports only web environment
19. SummarySummary
Cucumber follows Behavioral Driven DevelopmentCucumber follows Behavioral Driven Development
First Business Analyst/Product Owner writes the Gherkin Scripts (inFirst Business Analyst/Product Owner writes the Gherkin Scripts (in
normal English), then we run the Gherkin script. Finally we write code tonormal English), then we run the Gherkin script. Finally we write code to
make this script passmake this script pass
Cucumber supports all programming language not only RubyCucumber supports all programming language not only Ruby
20. ReferencesReferences
Unit Testing,Unit Testing, http://softwaretestingfundamentals.com/unit-http://softwaretestingfundamentals.com/unit-
testing/testing/
Steps to perform Unit Testing,Steps to perform Unit Testing,
http://www.exforsys.com/tutorials/testing/unit-testing.htmlhttp://www.exforsys.com/tutorials/testing/unit-testing.html
Cucumber,Cucumber, https://cucumber.io/#whyhttps://cucumber.io/#why
Procedure to perform cucumber and Pros/Cons,Procedure to perform cucumber and Pros/Cons,
http://www.slideshare.net/selvanathankapilan/cucumber-http://www.slideshare.net/selvanathankapilan/cucumber-
gherkin-languagegherkin-language
Step by Step Procedure,Step by Step Procedure,
https://www.jetbrains.com/help/ruby/2016.1/creating-step-https://www.jetbrains.com/help/ruby/2016.1/creating-step-
definition.htmldefinition.html