Automatic functional testing easier than you thought Bartosz Cisek

391 views
325 views

Published on

Automatic functional testing easier than you thought Bartosz Cisek

Presented at Edinburgh Moodlemoot 2014
www.moodlemoot.ie

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
391
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Automatic functional testing easier than you thought Bartosz Cisek

  1. 1. Functional testing easier than you thought Bartosz Cisek Edu-Space.pl 16.04.2014 Bartosz Cisek Functional testing easier than you thought 1 / 20
  2. 2. Do not reinvent the wheel Moodle already has: • integrated testing framework • well defined building blocks • prepared scripts • detailed documentation Bartosz Cisek Functional testing easier than you thought 2 / 20
  3. 3. Requirements • php 5.4 • separate domain • Internet access (only for installation) Bartosz Cisek Functional testing easier than you thought 3 / 20
  4. 4. Installation • Download composer and let it do the rest. • Download Selenium, Java and chrome driver. Bartosz Cisek Functional testing easier than you thought 4 / 20
  5. 5. Setup second platform • First one runs test • Second one is being tested Bartosz Cisek Functional testing easier than you thought 5 / 20
  6. 6. Update configuration • $CFG→behat prefix • $CFG→behat dataroot • $CFG→behat wwwroot Bartosz Cisek Functional testing easier than you thought 6 / 20
  7. 7. Test run • Start Selenium command line java -jar selenium-server-standalone-2.NN.N.jar • Start behat command line php admin/tool/behat/cli/init.php vendor/bin/behat –config /behat/dataroot/behat/behat.yml • As an example run tests of default Moodle installation Bartosz Cisek Functional testing easier than you thought 7 / 20
  8. 8. Writing test cases • start favorite editor • yaml format • create a file with .feature extension in tests/behat directory Bartosz Cisek Functional testing easier than you thought 8 / 20
  9. 9. File structure @plugintype @plugintype_plugin Feature: feature name description Scenario: Short description of scenario step 1 step 2 Scenario: Another scenario to test this feature step 1 step 2 Bartosz Cisek Functional testing easier than you thought 9 / 20
  10. 10. Feature and Scenario • Feature – Human-readable list of scenarios that describes a feature. • Scenario – Human-readable list of steps to describe an expected behavior Bartosz Cisek Functional testing easier than you thought 10 / 20
  11. 11. Scenario steps • Steps – Human-readable sentences that describes an action. • Steps definitions – php classes written in mink dialect Bartosz Cisek Functional testing easier than you thought 11 / 20
  12. 12. Types of steps 1 • “Given” – describing the initial context example Given I log in as ”admin” Bartosz Cisek Functional testing easier than you thought 12 / 20
  13. 13. Types of steps 2 • “When“ – action that leads to a change example When I click on a link Bartosz Cisek Functional testing easier than you thought 13 / 20
  14. 14. Types of steps 3 • “Then” – check the results example Then I should see ”Moodle 101: Course Name” Bartosz Cisek Functional testing easier than you thought 14 / 20
  15. 15. Fixtures • Prepare predefined environment • Testing enrollment requires users and courses Given the following "courses" exist: | fullname | shortname | category | format | | Course 1 | COURSE1 | CAT1 | topics | | Course 2 | COURSE2 | CAT2 | | Bartosz Cisek Functional testing easier than you thought 15 / 20
  16. 16. Filtering • You can filter features to test with –tags or –name options Bartosz Cisek Functional testing easier than you thought 16 / 20
  17. 17. Continuous Integration Manager • Jenkins • Computers are good at repeating procedures • Automate mundane tasks Bartosz Cisek Functional testing easier than you thought 17 / 20
  18. 18. Automatic Workflow Bartosz Cisek Functional testing easier than you thought 18 / 20
  19. 19. Flexibility • Build script (ant, phing) • Repository (git, hg, svn) • Head less window manager – Xvfb Bartosz Cisek Functional testing easier than you thought 19 / 20
  20. 20. Summary • It is not rocket science! • http://docs.moodle.org/dev/Acceptance_testing Contact: • b.cisek@edu-space.pl • +48 604 874 555 Bartosz Cisek Functional testing easier than you thought 20 / 20

×