Testing Area/Behat Testing/Basics: Difference between revisions
From Mahara Wiki
< Testing Area | Behat Testing
No edit summary |
No edit summary |
||
Line 33: | Line 33: | ||
Scenario: Creating a Portfolio page | Scenario: Creating a Portfolio page | ||
Given I am logged in as the user "admin" with password "Password1" | Given I am logged in as the user "admin" with password "Password1" | ||
And | And I follow "Porfolio" | ||
When | And I follow "Pages" | ||
When I press "Create page" | |||
And I fill in the following: | |||
| Page title | This is where you put the title of the page | | |||
| Page description | This is where you type the description of the page | | |||
And I press "Save" | |||
And | And | ||
Then | Then |
Revision as of 09:36, 16 December 2014
How to write a Behat test
Behat tests are written in Gerkin language, which is English readable. You write the test in a text editor like Vim, Gedit or Eclipse. For beginners, Gedit is reccomended.
To write the test start with the feature, you are about to click around Mahara and test an area so say:
Feature: Creating a Portfolio page <- (the point of the test) In order to have a portfolio page in Mahara <- (What you are wanting to do) As a student <- (Who you are logging in as eg student, admin, institution admin) So I can save my work on my Portfolio page <- (How you benefit from it)
Scenario: Creating a Portfolio page <- (Describe what you are about to do to test it works) Given (Setting the scene, these are you pre conditions) And (Use as many And's as you need to set the pre conditions) When (This is an action you do like clicking or pressing a button) And (Use as many And's as you need to describe the action you are doing like pushing 10 buttons to get to the place you want) Then (This is the achieveable outcome. Often it's what you see when the link you clicked worked.) And (Use as many And's as you need)
Write down every link you click and every button you pushed to create the page using the specific Behat syntax from this page [1]. These are you Given, And, When and Then steps.
Behat test example:
Feature: Creating a Portfolio page In order to have a Portfolio Page in Mahara As a student So I can save my work on my Portfolio page
Scenario: Creating a Portfolio page Given I am logged in as the user "admin" with password "Password1" And I follow "Porfolio" And I follow "Pages" When I press "Create page" And I fill in the following: | Page title | This is where you put the title of the page | | Page description | This is where you type the description of the page | And I press "Save" And Then And
You can follow the Behat documentation below on how to write a test:
[2]