Confused by testing terms and jargon? This talk walks through testing web applications, explaining the difference between unit testing and end to end testing. Several tools and concepts are also explored through a demo section.
Sample projects can be found at https://github.com/sethmcl/testing_web_applications.
6. js test driver
unit testing
integration tests
end to end testing
functional tests
mocha
phantomjs
casperjs
TDD
testacular
karma
venus
sinon
stubs
mocks
spies
fixtures
test harness
CI
expect
jasmine
intern
selenium headless browser
hudson travis
web driver
7. js test driver
unit testing
integration tests
end to end testing
functional tests
mocha
phantomjs
casperjs
TDD
testacular
karma
venus
sinon
stubs
mocks
spies
fixtures
test harness
CI
expect
jasmine
intern
selenium headless browser
hudson travis
web driver
???
8. PHILOSOPHIES
TDD, CI
CONSTRUCTS
test harness, mocks, fixtures,
stubs, spies, headless browser,
web driver
LIBRARIES
mocha, jasmine, qunit
chai, expect, sinon
METHODOLOGIES
unit testing, functional tests, end
to end testing, integration tests
TOOLS
phantomjs, casperjs, nightwatch, venus, js test
driver, karma, protractor, testacular, intern,
hudson, jenkins, travis, selenium
27. TestingEnd to End
start coding feature complete ship it!
define user scenarios
automate scenarios
test the tests
run in multiple browsers
JS PYTHON RUBY …
Run locally
Run in CI
Pick key features / user actions
28. TestingEnd to End
start coding feature complete ship it!
define user scenarios
automate scenarios
test the tests
run in multiple browsers
JS PYTHON RUBY …
Run locally
Run in CI
Pick key features / user actions
29. TestingEnd to End
start coding feature complete ship it!
define user scenarios
automate scenarios
test the tests
run in multiple browsers
JS PYTHON RUBY …
Run locally
Run in CI
Pick key features / user actions
•
• Login!
• Create Account!
• Complete Purchase!
• Send Message
30. TestingEnd to End
start coding feature complete ship it!
define user scenarios
automate scenarios
test the tests
run in multiple browsers
JS PYTHON RUBY …
Run locally
Run in CI
Pick key features / user actions
31. TestingEnd to End
start coding feature complete ship it!
define user scenarios
automate scenarios
test the tests
run in multiple browsers
JS PYTHON RUBY …
Run locally
Run in CI
Pick key features / user actions
32. TestingEnd to End
start coding feature complete ship it!
define user scenarios
automate scenarios
test the tests
run in multiple browsers
JS PYTHON RUBY …
Run locally
Run in CI
Pick key features / user actions
34. TEST HARNESS!
A special web page which includes only the
scripts and other resources necessary to run a
specific unit test.
!
MOCK / SPY / STUB!
Simulates components and functions which are
not available in the isolated unit testing
environment.
!
FIXTURE!
Fake data used to simulate user input or other
information needed for code to execute.
!
HEADLESS BROWSER!
Browser with no UI, useful for testing. Popular
example is PhantomJS.
http://phantomjs.org/
!
WEB DRIVER!
API browsers can implement to support
automation with tool such as Selenium.
http://www.w3.org/TR/webdriver/
Unit Testing
End to End Testing
36. MOCHA / JASMINE / QUNIT!
Provide APIs for writing and organizing unit
tests.
!
CHAI / EXPECT!
Provide APIs for writing test assertions. Some
libraries come with assertions built-in (Jasmine,
QUnit), and some let you to select your own
(Mocha).
!
SINON!
Helper library which provides mocks, stubs,
spies and other testing constructs.
!
Unit Testing
End to End Testing
38. PHANTOMJS / SLIMERJS!
PhantomJS is a headless Webkit based
browser. SlimerJS is a “mostly” headless
browser based on Firefox.
!
CASPERJS!
Higher-level abstraction over PhantomJS API,
to make it easier to write end to end tests.
!
VENUS / KARMA / INTERN!
Test runners (or, the “glue”) that ties all the
other tools together. Testacular was the original
name for Karma.
!
HUDSON / JENKINS / TRAVIS!
Continuous Integration tools. Travis is available
as a hosted service, with easy integration for
Github repositories. It is also free for open
source projects.
Unit Testing
End to End Testing
39. SELENIUM!
Collection of tools / APIs which enable
programmatic control of a web browser.
!
NIGHTWATCH!
Provides abstraction on top of Selenium API to
make writing end to end tests easier.
!
!
Unit Testing
End to End Testing