aikau testing tech talk live 83 20150204

18
Aikau Testing

Upload: david-webster

Post on 19-Jul-2015

189 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Aikau testing tech talk live 83 20150204

Aikau Testing

Page 2: Aikau testing tech talk live 83 20150204

Previously...

✔ Thorough application testingBut...✘ Poor unit testing of widgets✘ Difficulty spotting regressions✘ Difficulty keeping up with browser releases✘ Repetitive tests required for new features

Page 3: Aikau testing tech talk live 83 20150204

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.)

Page 4: Aikau testing tech talk live 83 20150204

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

Page 5: Aikau testing tech talk live 83 20150204

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?

Page 6: Aikau testing tech talk live 83 20150204

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

Page 7: Aikau testing tech talk live 83 20150204

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

Page 8: Aikau testing tech talk live 83 20150204

Youtube: https://www.youtube.com/watch?v=jAumAgznioM

Page 9: Aikau testing tech talk live 83 20150204

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

Page 10: Aikau testing tech talk live 83 20150204

Writing tests

Page 11: Aikau testing tech talk live 83 20150204

Test file location:

Test Model:

Test Code:

URL to test models:e.g. http://localhost:8089/aikau/page/tp/ws/AlfTabContainer

Page 12: Aikau testing tech talk live 83 20150204

Simple test model (just widget and pubsub log):

Complex test model (multiple widgets with buttons):

Page 13: Aikau testing tech talk live 83 20150204

“assert” framework prefered

Use setup to load page

Teardown to post coverage results

Multiple tests per suite

Single assert per test

Page 14: Aikau testing tech talk live 83 20150204

Call leadfoot method

pass result into then

check value

Find element

Page 15: Aikau testing tech talk live 83 20150204

Keyboard tests for accessibility

Test mouse interactions

Page 16: Aikau testing tech talk live 83 20150204

remote JS exec

avoid sleeps

then success shortcut

local var to compare before/after states

Page 17: Aikau testing tech talk live 83 20150204
Page 18: Aikau testing tech talk live 83 20150204

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