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 59: Line 59:
<h2>Tags</h2>
<h2>Tags</h2>


Always attach a @javascript tag
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.
 




Line 66: Line 73:
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:
  Feature: Creating a group
   In order to  
   In order to create a group
   As a
   As a student
   So I can  
   So I can become a part of the group and share my work


In order to  
* 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?





Revision as of 13:41, 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.



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


Scenario


Steps


Comments