Functional Testing- Application Testing Solution - Building ...
Introduction To Web Application Testing
-
Upload
ynon-perek -
Category
Technology
-
view
117 -
download
1
description
Transcript of Introduction To Web Application Testing
![Page 2: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/2.jpg)
Agenda
• Developing for the web. Why is it hard?
• What can you test?
• Testing architecture
![Page 3: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/3.jpg)
Why is it hard?
![Page 4: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/4.jpg)
Why is it hard?
• Many different browsers
• Many different devices
![Page 5: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/5.jpg)
Automatic testing is your only way out …
![Page 6: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/6.jpg)
Imagine …
• Short feedback loop on changes
• Reduce human mistakes
• TDD
![Page 7: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/7.jpg)
Types of TestsUnit tests System tests
http://johnny.github.io/jquery-sortable/
![Page 8: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/8.jpg)
Unit Tests
• During development, for the developer
• Instant feedback
• Future aware
• Easy to maintain
![Page 9: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/9.jpg)
System Tests
• Tests entire system
• For the client
• Easy to write
![Page 10: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/10.jpg)
What Can You Test?
• Everything …
• But you probably shouldn’t
![Page 11: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/11.jpg)
What Should You Test?
• Past bugs
• Intended behaviour
• Edge cases
![Page 12: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/12.jpg)
Testing Architecture
Mocha
JasmineIstanbulKarma PhantomJS
TeamCity
Jenkins
Selenium js-test-driver
ChutzpaCasperJS
Travis
QUnit
![Page 13: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/13.jpg)
Testing Architecture
index.html
main.js
car.js
race.js
style.css
![Page 14: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/14.jpg)
Testing Architecture
index.html
main.js
car.js
race.js
style.css
![Page 15: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/15.jpg)
Testing Architecture
index.html
main.js
car.js
race.js
style.css
test.html
mocha.js
car_test.js
![Page 16: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/16.jpg)
Testing Architecture
Mocha
Jasmine
Istanbul Karma
TeamCity
Jenkins
Selenium
js-test-driver
Chutzpa
CasperJS
TravisQUnit
Blanket
JSCoverage
![Page 17: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/17.jpg)
Unit Testing Framework
• Provides structure to test code
• Easy to report failures
• Written in JavaScript
![Page 18: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/18.jpg)
Unit Testing Framework
describe('Array', function(){ describe('#indexOf()', function(){ it('should return -1 when not present', function(){ [1,2,3].indexOf(5).should.equal(-1); [1,2,3].indexOf(0).should.equal(-1); }) }) })
![Page 19: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/19.jpg)
Unit Test Report
![Page 20: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/20.jpg)
Available Frameworks
• Mocha
• Jasmine
• QUnit
• http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript
![Page 21: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/21.jpg)
System Testing Tools
• Control an automatic browser
• Can use any programming language
![Page 22: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/22.jpg)
System Testingrequire "selenium-webdriver" !driver = Selenium::WebDriver.for :firefox driver.navigate.to "http://duckduckgo.com" !element = driver.find_element(:name, 'q') element.send_keys "Hello WebDriver!" element.submit !puts driver.title !driver.quit
![Page 23: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/23.jpg)
System Testing Tool
• We’ll use selenium
• It’s stable and flexible
• Really easy to automate
![Page 24: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/24.jpg)
Test Runners
• Run tests, report errors
• Used from command line or IDE
• Available options:
• Karma, Chutzpa, js-test-driver
![Page 25: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/25.jpg)
Continuous Integration
• Checkout latest from source control
• Run all tests
• Report failures
![Page 26: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/26.jpg)
Continuous Integration
• Travis
• Jenkins
• TeamCity
![Page 27: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/27.jpg)
Code Coverage
• % of the code being tested
• 70-80% is good
• Istanbul is the tool
![Page 28: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/28.jpg)
Coverage Report
![Page 29: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/29.jpg)
Balancing Tests
• Few system / scenario tests
• Many unit tests
![Page 30: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/30.jpg)
Resources• Chuzpa screencast for VS2012:
http://www.youtube.com/watch?v=meJ94rAN7P8
• Miško Hevery on Unit Tests (google tech talks): http://www.youtube.com/watch?v=wEhu57pih5w
![Page 31: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/31.jpg)
What Next
• Write unit tests
• Write functional tests
• Deploy a CI
• Set up coverage and test reports
![Page 32: Introduction To Web Application Testing](https://reader034.fdocuments.us/reader034/viewer/2022051110/54c82e8e4a7959e93d8b45f8/html5/thumbnails/32.jpg)
Ready? Let’s Go!
• Ynon Perek
• http://ynonperek.com