aikau testing tech talk live 83 20150204
TRANSCRIPT
Aikau Testing
Previously...
✔ Thorough application testingBut...✘ Poor unit testing of widgets✘ Difficulty spotting regressions✘ Difficulty keeping up with browser releases✘ Repetitive tests required for new features
Different routes to test AikauThere are potentially four ways to run an Aikau test:
1. With local browsers and a locally running instance of Selenium.(Pros: fast and viewable during development. Cons: limited to the local platform and browsers.)
2. With a local virtual machine running browsers and Selenium(Pros: fast and with fixed platforms and browsers for all developers. Cons: not so easily viewed during development.)
3. With a Selenium grid on your network(Pros: fixed set of platforms and browsers for all developers. Cons: not easily viewable and grid maintenance.)
4. Sauce Labs(Pros: Large number of platforms and browsers available and maintained externally. Cons: Commercial service, speed and connectivity issues.)
Intern files● src/test/resources/intern.js
Configuration for a virtual machine test run - associated with ‘grunt test’
● src/test/resources/intern_local.jsConfiguration for a local test run - associated with ‘grunt test_local’
● src/test/resources/intern_sl.jsConfiguration for a Sauce Labs test run - associated with ‘grunt test_sl’
● src/test/resources/config/Suites.jsConfiguration of all the tests to be run
The complete testing stackWhichever approach you are using to test Aikau you are going to be doing the following:
1. Connecting to or starting Selenium, to be available locally on port 4444 (this is configurable).
2. Running the Aikau TestApp with Jetty, making test examples of widgets available on a URL such as: http://localhost:8089/aikau/page/tp/ws/PdfJsPreview.(This task may be bundled into the following command)
3. Issuing a Grunt command that performs a number of tasks and then runs the configured suite of test files using Intern.
4. Looking at the test report and hopefully seeing a 100% pass. If not, why not?
Testing prerequisitesThe testing framework for Aikau makes use of a number of technologies and you will need the following free downloads if you wish to use it.
● Download and install VirtualBox● Download and install Vagrant● Download and install NodeJS
Running a test from scratchIf you’ve just checked out from GIT and want to run a test using the virtual machine, this is how it’s done.
1. Install dependencies: in the directory in which you checked out, run the following commands: >> npm install ... >> npm install grunt-cli -g
2. Start the virtual machine and therefore Selenium*: there is a Grunt command for this: >> g vup
3. Start a test: there is a Grunt command that cleans the code and starts the test app before running the virtual machine configured version of the Intern test runner: >> g test
* Selenium console appears at this address when successfully started: http://127.0.0.1:4444/wd/hub
Youtube: https://www.youtube.com/watch?v=jAumAgznioM
Useful resourcesAlfresco developer blogs
● http://blogs.alfresco.com/wp/developer/2014/10/30/getting-started-with-functional-unit-testing-of-aikau/● http://blogs.alfresco.com/wp/developer/2014/11/03/further-options-for-functional-unit-testing-of-aikau/
Intern documentation● http://theintern.io/● http://theintern.github.io/leadfoot/
YouTube video● https://www.youtube.com/watch?v=jAumAgznioM
Writing tests
Test file location:
Test Model:
Test Code:
URL to test models:e.g. http://localhost:8089/aikau/page/tp/ws/AlfTabContainer
Simple test model (just widget and pubsub log):
Complex test model (multiple widgets with buttons):
“assert” framework prefered
Use setup to load page
Teardown to post coverage results
Multiple tests per suite
Single assert per test
Call leadfoot method
pass result into then
check value
Find element
Keyboard tests for accessibility
Test mouse interactions
remote JS exec
avoid sleeps
then success shortcut
local var to compare before/after states
More Info:Aikau Project: https://github.com/Alfresco/Aikau
Project Plans: https://issues.alfresco.com/jira/browse/AKU
Documentation: https://wiki.alfresco.com/wiki/Aikau_framework
A link to the video is on the events page: https://plus.google.com/events/cd7sbudin7ua1ncq82p0vbiijd4