Note: You are currently viewing documentation for Moodle 2.6. Up-to-date documentation for the latest stable version of Moodle may be available here: Dataform Tests.

Dataform Tests: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
{{Dataform Docs Note 1}}
{{Dataform Docs Note 1}}
==Unit tests==
==Unit tests==
TBC
===Generator===
====Create instance====
Creates a dataform instance.
====Duplicate instance====
Creates a duplicate of an existing dataform instance in a specified course. Uses activity backup/restore.
====Delete instance====
Deletes a dataform instance.
====Delete all instances====
Deletes all dataform instances in a specified course or in site.
====Create view====
Creates a dataform view.
====Create field====
Creates a dataform field.
====Create entry====
Creates a dataform entry.
===Available test cases===
====Generator====
Dataform instance creation and gradebook integration.
====Events====
Triggers, captures and validate events for:
*View
*Field
*Filter
*Entry
====Access====
Validates access for:
*entry view
*entry add
*entry update
*entry delete
*field view
*field update
*view access
====CSV Import====
Import of base patterns of standard fields.
====Backup/restore====
*Test duplicate
==Acceptance tests==
==Acceptance tests==
Administrator can run Dataform acceptance tests with the Moodle behat command line tool (see https://docs.moodle.org/dev/Acceptance_testing#Running_tests).
===Available features===
 
====Basics====
Alternately administrator can use the Dataform Acceptance testing interface from
*Adds a Dataform activity to a course.
 
*Adds all standard fields with default settings.
''Administration > Site administration > Plugins > Activity modules > Dataform > Acceptance testing''
*Adds all standard views with default settings.
 
*Submits a new entry with content in the text field in each view.
for testing particular Dataform features by name or tags.
*Sets quick filter
 
**Sets quick per page and navigates between pages with the paging bar
The current implementation of the Dataform Acceptance testing interface assumes that a selenium server is running. To run a test, select a feature or tags and click 'Run tests'. The page will hang until the tests are completed. If you run long tests it may be better to run them from a command line.
**Filters entries with the quick search
 
**Resets the quick filter
[[File:df-acceptance-testing.png]]
*Adds standard filters with sort and search criteria and applies them to the view
*Adds advanced (user) filter and applies it to the view
====Max entries====
====Max entries with interval====
====Not ready====
====Separate participants====
===Available steps===
===Available steps===
====Given I start afresh with dataform "DATAFORM_NAME_STRING"====
====I start afresh with dataform "DATAFORM_NAME_STRING"====
Prepares  a fresh environment with the following components and a dataform activity 'Test dataform' in Course 1.
Prepares  a fresh environment with the following components and a dataform activity 'Test dataform' in Course 1.
Course:
Course:
Line 50: Line 91:


This step is essential for any standalone scenario that adds or updates entries with content since such a scenario has to refer to input elements by fixed field ids and entry ids.
This step is essential for any standalone scenario that adds or updates entries with content since such a scenario has to refer to input elements by fixed field ids and entry ids.
 
====I run dataform scenario "SCENARIO_NAME_STRING" with:====
====Given I go to dataform page "DATAFORM_URL_STRING"====
Runs the specified scenario with specified data. See [[#Scenario templates]].
====I go to dataform page "DATAFORM_URL_STRING"====
Opens Dataform url.
Opens Dataform url.
 
====I add a dataform with "DATAFORM_URL_STRING"====
====Given I add a dataform with "DATAFORM_URL_STRING"====
Adds a dataform as teacher 1 in course 1 and displays the dataform.
Adds a dataform as teacher 1 in course 1 and displays the dataform.
 
====the dataform settings should match "FORM_DATA_STRING"====
====Then the dataform settings should match "FORM_DATA_STRING"====
Validates dataform activity settings.
Validates dataform activity settings.
 
====I add a test dataform====
====Given I add a test dataform====
Adds a test dataform as teacher 1 in course 1 and displays the dataform.
Adds a test dataform as teacher 1 in course 1 and displays the dataform.
 
====I delete this dataform====
====Given I delete this dataform====
Deletes the dataform.
Deletes the dataform.
 
====I go to manage dataform "TAB_NAME_STRING"====
====Given I go to manage dataform "TAB_NAME_STRING"====
Go to the specified manage tab of the current dataform.
Go to the specified manage tab of the current dataform.
 
====I add a dataform field "FIELD_TYPE_STRING" with "FORM_DATA_STRING"====
====Given I add a dataform field "FIELD_TYPE_STRING" with "FORM_DATA_STRING"====
Adds a field of the specified type to the current dataform with the provided table data (usually Name).
Adds a field of the specified type to the current dataform with the provided table data (usually Name).
 
====I add a dataform view "VIEW_TYPE_STRING" with "FORM_DATA_STRING"====
====Given I add a dataform view "VIEW_TYPE_STRING" with "FORM_DATA_STRING"====
Adds a view of the specified type to the current dataform with the provided table data (usually Name).
Adds a view of the specified type to the current dataform with the provided table data (usually Name).
 
====I set view "VIEW_NAME_STRING" as default view====
====Given I set view "VIEW_NAME_STRING" as default view====
Sets a view as the default view of a dataform instance.
Sets a view as the default view of a dataform instance.
 
====I add a dataform filter with "FORM_DATA_STRING"====
====Given I add a dataform filter with "FORM_DATA_STRING"====
Adds a filter with the specified data to the current dataform.
Adds a filter with the specified data to the current dataform.
 
====I prepend "TEXT_STRING" to field "FIELD_STRING"====
====Given I prepend "TEXT_STRING" to field "FIELD_STRING"====
Prepends text to the field's content.
Prepends text to the field's content.
====I apppend "TEXT_STRING" to field "FIELD_STRING"====
Appends text to the field's content.
====I set dataform field "FIELD_NAME_STRING" options to "OPTIONS_STRING"====
Sets a dataform field setting to the given content.
====I set the field "FIELD_NAME_STRING" to====
Sets field value to the specified text passed as PyStringNode.
====I fill textarea "FIELD_STRING" with "TEXT_STRING" ====
Fills a textarea with the specified text replacing \n with new lines.
===Scenario templates===
====Manage view====
Performs view add update delete in the views index.


====Given I apppend "TEXT_STRING" to field "FIELD_STRING"====
Usage:
Appends text to the field's content.
@javascript
Scenario: Manage view
    Given I run dataform scenario "manage view" with:
        | viewtype | aligned |
====Manage field====
Performs field add update delete in the fields index.


====Given I set dataform field "FIELD_NAME_STRING" options to "OPTIONS_STRING"====
Usage:
Sets a dataform field setting to the given content.
@javascript
Scenario: Manage field
    Given I run dataform scenario "manage field" with:
        | fieldtype | text |
====View required field====
Tests adding an entry with required field in the specified view.


====Given I set the field "FIELD_NAME_STRING" to====
Usage:
Sets field value to the specified text passed as PyStringNode.
@javascript
Scenario: Required field
    Given I run dataform scenario "view required field" with:
        | viewtype      | aligned      |
        | entrytemplate | Entry template|


====Given I fill textarea "FIELD_STRING" with "TEXT_STRING" ====
====View submission buttons====
Fills a textarea with the specified text replacing \n with new lines.
Tests the various submission methods in the specified view.


===Available tests===
Usage:
====Add dataform====
@javascript
====Add fields====
Scenario: Submission buttons
====Add filters====
    Given I run dataform scenario "view submission buttons" with:
====Add views====
        | viewtype  | aligned  |
====Add entries with no fields====
        | actor    | student1  |
====Add entries with all fields====
===Step values===
====Add entries with field checkbox====
====FORM_DATA_STRING====
====Add entries with field select====
====Add entries with field select multiple====
====Add entries with field text====
==See also==
==See also==
*[https://docs.moodle.org/dev/Acceptance_testing Acceptance testing] - information about preparing your Moodle installation for acceptance testing. Note that this is not recommended for production sites.
*[https://docs.moodle.org/dev/Acceptance_testing Acceptance testing] - information about preparing your Moodle installation for acceptance testing. Note that this is not recommended for production sites.
*[https://docs.moodle.org/dev/Acceptance_testing#Writing_features Writing features] - general test writing guidelines.
*[https://docs.moodle.org/dev/Acceptance_testing#Writing_features Writing features] - general test writing guidelines.

Latest revision as of 14:23, 11 May 2014


Unit tests

Generator

Create instance

Creates a dataform instance.

Duplicate instance

Creates a duplicate of an existing dataform instance in a specified course. Uses activity backup/restore.

Delete instance

Deletes a dataform instance.

Delete all instances

Deletes all dataform instances in a specified course or in site.

Create view

Creates a dataform view.

Create field

Creates a dataform field.

Create entry

Creates a dataform entry.

Available test cases

Generator

Dataform instance creation and gradebook integration.

Events

Triggers, captures and validate events for:

  • View
  • Field
  • Filter
  • Entry

Access

Validates access for:

  • entry view
  • entry add
  • entry update
  • entry delete
  • field view
  • field update
  • view access

CSV Import

Import of base patterns of standard fields.

Backup/restore

  • Test duplicate

Acceptance tests

Available features

Basics

  • Adds a Dataform activity to a course.
  • Adds all standard fields with default settings.
  • Adds all standard views with default settings.
  • Submits a new entry with content in the text field in each view.
  • Sets quick filter
    • Sets quick per page and navigates between pages with the paging bar
    • Filters entries with the quick search
    • Resets the quick filter
  • Adds standard filters with sort and search criteria and applies them to the view
  • Adds advanced (user) filter and applies it to the view

Max entries

Max entries with interval

Not ready

Separate participants

Available steps

I start afresh with dataform "DATAFORM_NAME_STRING"

Prepares a fresh environment with the following components and a dataform activity 'Test dataform' in Course 1. Course:

| fullname | shortname | category
| Course 1 | C1 | 0

Users:

| username | firstname | lastname | email
| teacher1 | Teacher | 1 | teacher1@asd.com
| assistant1 | Assistant | 1 | assistant1@asd.com
| student1 | Student | 1 | student1@asd.com
| student2 | Student | 2 | student2@asd.com
| student3 | Student | 3 | student3@asd.com

Enrollments:

| user | course | role
| teacher1 | C1 | editingteacher
| assistant1 | C1 | teacher
| student1 | C1 | student
| student2 | C1 | student

Groups:

| name    | description | course  | idnumber |
| Group 1 | Anything    | C1 | G1   |
| Group 2 | Anything    | C1 | G2   |

Group members:

| user     | group  |
| student1 | G1 |        
| student2 | G2 |        

It also resets (truncates) all Dataform tables to remove any records and reset sequences.

This step is essential for any standalone scenario that adds or updates entries with content since such a scenario has to refer to input elements by fixed field ids and entry ids.

I run dataform scenario "SCENARIO_NAME_STRING" with:

Runs the specified scenario with specified data. See #Scenario templates.

I go to dataform page "DATAFORM_URL_STRING"

Opens Dataform url.

I add a dataform with "DATAFORM_URL_STRING"

Adds a dataform as teacher 1 in course 1 and displays the dataform.

the dataform settings should match "FORM_DATA_STRING"

Validates dataform activity settings.

I add a test dataform

Adds a test dataform as teacher 1 in course 1 and displays the dataform.

I delete this dataform

Deletes the dataform.

I go to manage dataform "TAB_NAME_STRING"

Go to the specified manage tab of the current dataform.

I add a dataform field "FIELD_TYPE_STRING" with "FORM_DATA_STRING"

Adds a field of the specified type to the current dataform with the provided table data (usually Name).

I add a dataform view "VIEW_TYPE_STRING" with "FORM_DATA_STRING"

Adds a view of the specified type to the current dataform with the provided table data (usually Name).

I set view "VIEW_NAME_STRING" as default view

Sets a view as the default view of a dataform instance.

I add a dataform filter with "FORM_DATA_STRING"

Adds a filter with the specified data to the current dataform.

I prepend "TEXT_STRING" to field "FIELD_STRING"

Prepends text to the field's content.

I apppend "TEXT_STRING" to field "FIELD_STRING"

Appends text to the field's content.

I set dataform field "FIELD_NAME_STRING" options to "OPTIONS_STRING"

Sets a dataform field setting to the given content.

I set the field "FIELD_NAME_STRING" to

Sets field value to the specified text passed as PyStringNode.

I fill textarea "FIELD_STRING" with "TEXT_STRING"

Fills a textarea with the specified text replacing \n with new lines.

Scenario templates

Manage view

Performs view add update delete in the views index.

Usage:

@javascript
Scenario: Manage view
    Given I run dataform scenario "manage view" with:
        | viewtype | aligned |

Manage field

Performs field add update delete in the fields index.

Usage:

@javascript
Scenario: Manage field
    Given I run dataform scenario "manage field" with:
        | fieldtype | text |

View required field

Tests adding an entry with required field in the specified view.

Usage:

@javascript
Scenario: Required field
    Given I run dataform scenario "view required field" with:
        | viewtype      | aligned       |
        | entrytemplate | Entry template|

View submission buttons

Tests the various submission methods in the specified view.

Usage:

@javascript
Scenario: Submission buttons
    Given I run dataform scenario "view submission buttons" with:
        | viewtype  | aligned   |
        | actor     | student1  |

Step values

FORM_DATA_STRING

See also

  • Acceptance testing - information about preparing your Moodle installation for acceptance testing. Note that this is not recommended for production sites.
  • Writing features - general test writing guidelines.