Date post: | 14-Jan-2015 |
Category: |
Technology |
Upload: | dimakovalenko |
View: | 494 times |
Download: | 0 times |
Dima Kovalenko
@dimacuswww.agilesoftwaretesting.comwww.dimakovalenko.comlinkedin.com/in/dimakovalenko
Past Experience
Disclaimer
> Dima.kind_of?(Developer)=> false
Why automated tests?
Why automated tests?
•Too expensive
•Too much work to create
•Not enough staff to maintain
•Never know the coverage level
•No one but developers knows what is being tested
We don’t need Automated Tests!
We don’t need Automated Tests!
The EndSee You all at Selenium 2012!
Selenium and Cucumber
Img Source: http://pickledillies.homestead.com/
Overview
•Set the stage
•Introduce Cucumber
•Good features
•Bad features
•???
•Profit!
Assumptions
•Startup or small business
•Understaffed
•Inadequate test coverage
•Need to defend existence of having automated tests to business.
The Stage
The Stage
•First casualty of an agile development environment is documentation. - me
The Stage
•First casualty of an agile development environment is documentation. - me
•No written test cases to speak of
The Stage
•First casualty of an agile development environment is documentation. - me
•No written test cases to speak of
•Need to deliver features, NOW!!!
The Stage
•First casualty of an agile development environment is documentation. - me
•No written test cases to speak of
•Need to deliver features, NOW!!!
•Groupon: Weekly deployments
The Stage•First casualty of an agile
development environment is documentation. - me
•No written test cases to speak of
•Need to deliver features, NOW!!!
•Groupon: Weekly deployments
•IMVU: Up to 50 deploys a day• http://timothyfitz.wordpress.com/2009/02/10/continuous-d
eployment-at-imvu-doing-the-impossible-fifty-times-a-day/
Why automated tests?
•Too expensive
•Too much work to create
•Not enough staff to maintain
•Never know the coverage level
•No one but developers knows what is being tested
Cucumber
Cucumber
•A BDD framework to help with TDD and other TLAs
Cucumber
•A BDD framework to help with TDD and other TLAs
•It’s Agile, Promotes Synergy, Enterprise, will shift Paradigms and completely Web 2.0
Cucumber
•A BDD framework to help with TDD and other TLAs
•It’s Agile, Promotes Synergy, Enterprise, will shift Paradigms and completely Web 2.0
•You too can be BUZZ WORD compliant!
Img Source: http://www.themoreyouknow.com/
Natural Language@searchFeature: Searching For Hello World, and some more overview of the feature that we are trying to test
@google Scenario: User Searches for Hello World on Google.com Given I'm on Google's Home Page And I search for Hello World
Then I should see Wikipedia's Hello World article as 1st result
@bing Scenario: User Searches for Hello World on Bing.com Given I'm on Bing's Home Page And I search for Hello World
Then I should see car videos as first result
Step DefinitionsGiven /^I'm on Google's Home Page$/ do @selenium.open "www.google.com"end
Given /^I'm on Bing's Home Page$/ do @selenium.open "www.bing.com"end
When /^I search for Hello World$/ do @selenium.type "q", "Hello World"end
Then /^I should see Wikipedia's Hello World article as 1st result$/ do assert_stuffend
Then /^I should see car videos as first result$/ do assert_stuffend
Why automated tests?
•Too expensive
•Too much work to create
•Not enough staff to maintain
•Never know the coverage level
•No one but developers knows what is being tested
Who should be writing tests?
Who should be writing tests?
•Developers
•Unit, Integration, Functional
Who should be writing tests?
•Developers
•Unit, Integration, Functional
•QAs
•Functional, End-To-End
Who should be writing tests?
•Developers
•Unit, Integration, Functional
•QAs
•Functional, End-To-End
•Everyone else
•At least the feature definitions
Why automated tests?
•Too expensive
•Too much work to create
•Not enough staff to maintain
•Never know the coverage level
•No one but developers knows what is being tested
Mind Map Solution
Why automated tests?
•Too expensive
•Too much work to create
•Not enough staff to maintain
•Never know the coverage level
•No one but developers knows what is being tested
Good Features•Tags
•Encourages BDD/TDD
•Supports multiple test drivers
•Selenium 1 and Selenium 2 support
•Multilingual
• i18n support
•Readable test results
Tags@searchFeature: Searching For Hello World, and some more overview of the feature that we are trying to test
@google @selenium Scenario: User Searches for Hello World on Google.com Given I'm on Google's Home Page And I search for Hello World
Then I should see Wikipedia's Hello World article as 1st result
@bing Scenario: User Searches for Hello World on Bing.com Given I'm on Bing's Home Page And I search for Hello World
Then I should see car videos as first result
Tags@searchFeature: Searching For Hello World, and some more overview of the feature that we are trying to test
@google @selenium Scenario: User Searches for Hello World on Google.com Given I'm on Google's Home Page And I search for Hello World
Then I should see Wikipedia's Hello World article as 1st result
@bing Scenario: User Searches for Hello World on Bing.com Given I'm on Bing's Home Page And I search for Hello World
Then I should see car videos as first result
Encourages BDD/TDD
•Write feature description first
•Run test see it fail
•Create one step definition at the time
•Write functionality for the step
•Run test see it pass
First run
First run
Write Step Definitions
Write More Step Definitions
Even More Step Definitions
Multiple Test Drivers
Steam
CelerityCulerity
FireWatirSafariWatir
ChromeWatir Img Source: Wikipedia
Selenium 1 supportBefore do |scenario| @selenium = Selenium::Client::Driver.new( :host => "localhost", :port => 4444, :browser => “firefox”, :url => “www.google.com”)end
Selenium 1 Tip
Use Hpricot Or Nokogiri!!!
page = Hpricot(@selenium.get_html_source)
Selenium 2 support
Selenium 2 support
•Capybara + Selenium = Love
Selenium 2 support
•Capybara + Selenium = Love
•Capybara + Selenium + Rails = .......
Capybara
•Uses Nokogiri
•Uses XPath outside of browser
•Works outside of rails
MultilingualJVM: JRuby, Java
.NET: IronRuby, IronRuby .NET, MonoAdoby Flex: FunFX, Melomel
PythonErlangGroovyScala
ClosureJavascript
Spring
Java Step Definitionpackage cukes;
import cuke4duke.annotation.I18n.EN.Given;import java.util.List;import java.util.ArrayList;
public class BellySteps { private List<String> belly = new ArrayList<String>();
@Given("I have (\\d+) cukes in my belly") public void bellyCukes(int cukes) { for(int i = 0; i < cukes; i++) { belly.add("cuke " + i); } }}
i18n
i18nФункционал: Сложение чисел Чтобы не складывать в уме Все, у кого с этим туго Хотят автоматическое сложение целых чисел
Сценарий: Сложение двух целых чисел Допустим я ввожу число 50 И затем ввожу число 70 Если я нажимаю "+" То результатом должно быть число 120
i18n Chinese
功能 : 加法 為了避免愚蠢的錯誤 作為一個數學白痴 我希望有人能告訴我兩個數相加的結果
場景大綱 : 將兩個數相加 假設我已經在計算機上輸入 < 數值 _1> 而且我已經在計算機上輸入 < 數值 _2> 當我按下 < 按鈕 > 那麼螢幕上應該顯示 < 結果 >
i18n LOLz
OH HAI: STUFFING
MISHUN: CUCUMBR I CAN HAZ IN TEH BEGINNIN 3 CUCUMBRZ WEN I EAT 2 CUCUMBRZ DEN I HAS 2 CUCUMBERZ IN MAH BELLY AN IN TEH END 1 CUCUMBRZ KTHXBAI
Readable Test Results
Bad Features
•Regex step definitions
•Hard To find Step Definitions
•Slower
•Natural language parser
•Messy directory structure
Regex Step Definitions
•Good: Reuse Definitions
•Bad:
• Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do
Hard to find Step Definitions
cucumber-tmbundle
Vim Rails
Bad Features
•Regex step definitions
•Hard To find Step Definitions
•Slower
•Natural language parser
•Messy directory structure
Conclusion
•Cucumber is a great tool to
•Describe Features
•Document Features
•Get the whole team involved
•However, it has downsides also
@dhhRSpec offends me aesthetically with no discernible benefit for its added complexity over test/unit.
@dhhRSpec offends me aesthetically with no discernible benefit for its added complexity over test/unit.
Cucumber makes no sense to me unless you have clients reading the tests. Why would you build a test-specific parser for English?
@dhhRSpec offends me aesthetically with no discernible benefit for its added complexity over test/unit.
Cucumber makes no sense to me unless you have clients reading the tests. Why would you build a test-specific parser for English?
The important thing is of course that we get people testing, so tools shouldn't matter too much....
Work @ Groupon
www.groupon.com/techjobs
The End