Francois Reynoud
Selenium Grid
Less Selenium, more unit testing
(With Jasmine)Dima Kovalenko
@dimacus
What do you use for “in browser” testing?
Selenium has some issues
Selenium Issues
• Reliability / Stability
Stability
Selenium Stability Last 2 months
Selenium Stability Last 12 months
Selenium Issues
• Reliability / Stability• Speed
Build Time – 400 Selenium on 3 machines 6 parallel cores
Typical Selenium Flow
Typical Selenium Flow
Typical Selenium Flow
Typical Selenium Flow
Source: GIS
Why so slow?
• Browser speed• JS speed• Machine speed• External URLs
Selenium Issues
• Reliability / Stability• Speed• Internet Explorer / Browser Compatibility
Internet Explorer
Source: GIS
Don’t use Selenium to test JavaScript!
Use it to test application flow instead.
http://pivotal.github.com/jasmine/
Jasmine
• Reliability / Stability
Jasmine
• Reliability / Stability• Browser Compatibility
Jasmine
• Reliability / Stability• Browser Compatibility • Speed
Build Time (3,500+ tests)
Jasmine is a BDD tool
(Behavior Driven Development)
What is BDD
In software engineering, behavior-driven development (abbreviated BDD) is a software development process based on test-driven development (TDD).[1][2] Behavior-driven development combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software developers and business analysts with shared tools
and a shared process to collaborate on software development.
Source: Wikipedia
BDD In the Nutshell
Write tests that describe application flow.
What BDD looks like
“Purchase flow should accept VISA”
Jasmine Test Sample
It’s Just Functions!
• “describe” “context” “it”…• Can use any JS code to make a test work
Jasmine Features
• Mocks / Spies• Fixtures• Matchers• Setup / Teardown• Asynchronous Support and Callbacks
Mocks / Spies
• Double any function• Monitors the calls the function• Monitors the arguments passed in• Can create a “bare” spy• Mock the Clock
Fixtures
• Adding elements to page on the fly
Matchers
• expect()• toEqual()• not()• toBeFalsy()• toThrow()• Custom matchers
Setup / Teardown
• beforeEach()• afterEach()
Asynch support
• Using spies to verify Callbacks• runs()• waitsFor()
What it is written in
• HTML• JavaScript• Ruby– Rake– ERB– Rspec
Workflow in Ruby
• Rake• ERB (Generate HTML)• Selenium• Tests in Loaded JS• Rspec
Environments supported
• Ruby• Rails• Spider Monkey• Node• Scala• Java• Django• .Net• Perl• HTML
Installation
• gem install jasmine• jasmine init
Questions?