GAIA INTEGRATION TESTS
using THE MARIONETTE JS RUNNER
Germán Toro del Valle
agenda (for quick access)
- Unit tests vs. Integration tests
- Why integration tests?
- What is Marionette?
- The Marionette JS Runner
- Running our first integration test
- Basic integration test structure
- Instantiating the Marionette client
- Client: Configuration
- Client: Setting the context
- Client: Getting information
- Client: Navigating
- Client: Finding elements
...
agenda (for quick access)
...
- Client: Executing scripts
- Client: Other
- Element: Getting info
- Element: Interaction
- Element: Finding children
- Element: Executing scripts
- Element: Other
- Client: Helper extension
- Client: App extension
- Client: Actions extension
...
agenda (for quick access)
...
UNIT vs. integration tests
-
/apps/communications/contacts/test/unit/navigation_test.js
- Author: @gtorodelvalle (git blame on me :-p )
- This "unit" test:
- Checks that the Contacts app navigation library works as expected
- Mocks the UI
- Dispatches events (animetionend) as the communication means among the involved components
THIS IS NOT A UNIT TEST!!!
why integration tests?
What is Marionette?
- Marionette is an automation driver
- Marionette runs as a server
- Marionette makes it possible to send commands to a program built on the Gecko platform (Firefox, Firefox OS):
- Simulating UI interactions
- Running JavaScript code
- Marionette extends the concept of the Selenium/WebDriver to interact with a remote test environment
- Clients:
THE MARIONETTE JS RUNNER
running our first integration test
- Pre-requisites: Node.js >= 0.10
git clone https://github.com/mozilla-b2g/gaia.git
make test-integration [VERBOSE=1] [APP=<app-name> | TEST_FILES="<path-to-test-1> <path-to-test-2> ..."]
export VERBOSE=1
export APP=communications
export TEST_FILES="<path-to-test-1> <path-to-test-2> ..."
$GAIA/bin/gaia-marionette
$GAIA/bin/gaia-marionette-parallel
# To avoid the b2g-desktop windows from showing for every test.
xvfb-run make test-integration
# To avoid hearing sounds.
PULSE_SERVER=":" make test-integration
PULSE_SERVER=":" xvfb-run make test-integration
# To avoid the b2g-desktop windows from showing for every test and to avoid hearing sounds.
PROFILE_FOLDER=profile-test make # generate profile directory in first time
make test-integration-test
BASIC INTEGRATION TEST STRUCTURE
INSTANTIATING THE MARIONETTE CLIENT
client: CONFIGURATION
client: setting the context
client: GETTING INFORMATION
client: NAVIGATING
client: FINDING ELEMENTS
client: EXECUTING SCRIPTS
client: OTHER
Element: Getting info
Element: INTERACTION
Element: FINDING CHILDREN
Element: EXECUTING SCRIPTS
Element: OTHER
CLIENT: HELPER EXTENSION
CLIENT: APP EXTENSION
client: actions extENSION
client: MULTI-actions extENSION
Final tricks: Launching apps
Final tricks: Importing scripts
Final tricks: Internationalization
Final tricks: Transitions / Animations
Final tricks: simulating dom events
- element.click(), element.tap() sometimes just don't work
final tricks: INTERMITTENT failures
- Forcing may runs in a row to detect intermittent failures:
- Activate Travis in your forked repository from mozilla-b2g/gaia using https://travis-ci.org/profile
- Update .travis.yml according to https://gist.github.com/KevinGrandon/8047042 and add it to your patch
- Send a PR to your forked repository master branch
- Wait for Travis' veredict
REFERENCES
- Gaia integration tests
- mozilla-b2g/gaia/README.md
- Marionette JavaScript runner
- Marionette JavaScript client
- Marionette JavaScript client API docs
- Marionette Python client API docs
- IRC chat rooms:
-
irc://irc.mozilla.org/#ateam
- irc://irc.mozilla.org/#qa
Gaia Integration Tests using Marionette JS Runner
By Germán Toro del Valle
Gaia Integration Tests using Marionette JS Runner
- 6,649