Actions

Testing Area/Behat Testing/Characteristics of a good test: Difference between revisions

From Mahara Wiki

< Testing Area‎ | Behat Testing
No edit summary
No edit summary
Line 72: Line 72:
<h2>Feature</h2>
<h2>Feature</h2>
Behat docs on Features:[http://docs.behat.org/en/v2.5/guides/1.gherkin.html#features]
Behat docs on Features:[http://docs.behat.org/en/v2.5/guides/1.gherkin.html#features]
Good features clearly explain what you are trying to do. If you are using a bug from Launchpad to write the test, use the title of the bug in the title of the feature.  
 
*Good features clearly explain what you are trying to do. If you are using a bug from Launchpad to write the test, use the title of the bug in the title of the feature.  


  Feature: Creating a group
  Feature: Creating a group

Revision as of 14:59, 16 December 2014

How to write a good test

Template

Copy and paste into your text editor and remember to save in the right directory and as a .feature file

Single scenario on a page

 @javascript @core
 Feature: 
  In order to 
  As an
  So I can

 Scenario:
  Given
  And
  When
  And
  Then 


Multiple scenarios on one page.

 @javascript @core 
 Feature: 
  In order to 
  As an
  So I can

 Background:
  Given
  And
  And
  And  

 @core_
 Scenario:
  Given
  And
  When
  And
  Then 

 @core_
 Scenario:
  Given
  And
  When
  And
  Then



Tags

The tags are how we run the tests, to run a group of tests on Jenkins at once we identify the ones to run by the tag.

  • Always attach an @javascript tag to the top of the page. This will run all the scenarios on the page, don't tag each scenario with @javasript. One at the top is enough.
  • If it's testing a core feature tag it @core, this will be all tests except 3rd party plugins.
  • Tags at the top of the page, run all the scenarios on the page.
  • Tags on the scenarios just run those scenarios.
  • If there are multiple scenarios on the page and they are testing are testing multiple parts of a feature, tag the top of the scenario appropriately.
  • A


Feature

Behat docs on Features:[1]

  • Good features clearly explain what you are trying to do. If you are using a bug from Launchpad to write the test, use the title of the bug in the title of the feature.
Feature: Creating a group
 In order to create a group 
 As a student
 So I can become a part of the group and share my work
  • The first line of the feature is the title of what you are testing
  • In order to do something specific
  • As an, who you are logging in as (remember if you are logggin in as a student you first need to have the student account created, use the background for this
  • So I can, tell us what the end game is here. So you can do what?


Background

Behat docs on backgrounds:[2]

  • Backgrounds come after the feature and before the first scenario and cannot be placed on any other part of the test.
  • Backgrounds are good for efficiency and save you from having to write the same steps over and over again. Use a background to log in as an admin, create users, create groups and all the prerequisites you need to test as that user.
  • Backgrounds are used when you have multiple scenarios on the page that use the same prerequisites. For example, both scenarios need 4 users to be a part of group so they can share pages to the group. The background would be used to create the four users and then group. The scenario steps would then log in and share the a page to the group and then verify that the page was shared.


Scenario


Steps


Comments