Note: You are currently viewing documentation for Moodle 3.9. 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
Line 16: Line 16:
[[File:df-acceptance-testing.png]]
[[File:df-acceptance-testing.png]]
===Available steps===
===Available steps===
====I start afresh====
====Given I start afresh====
* Resets (truncates) all dataform tables to remove any records and reset sequences.
Resets (truncates) all dataform tables to remove any records and reset sequences.
* This step is essential for any standalone scenario that adds entries with content since such a scenario has to refer to input elements by the name field_{fieldid}_{entryid} (or field_{fieldid}_-1 for a new entry) and the ids have to persist between runs.
====I add a test dataform====
* Adds a test dataform as teacher 1 in course 1 and displays the dataform.
* The step begins in a new test site.
====I delete this dataform====
* Deletes the dataform.
* This step begins inside the designated dataform.
* Useful at the end of standalone scenarios for cleanup.
====I go to manage dataform "TABNAME_STRING"====
* Goes to the specified manage tab of the current dataform.
* The step begins from the dataform's course page.


Example:
====Given I start afresh with dataform "DATAFORM_NAME_STRING"====
<nowiki>
Starts afresh with a dataform activity 'Test dataform' in Course 1.
And I go to manage dataform “filters”
</nowiki>
====I add a dataform field "FIELDTYPE_STRING" with "SETTINGSLIST_STRING"====
* Adds a field of the specified type to the current dataform with the provided table data (usually Name).
* The step begins from the dataform's course page.


'''Example''':
====Given I go to dataform page "DATAFORM_URL_STRING"====
<nowiki>
Opens Dataform url.
And I add a dataform field "checkbox" with "Field 01 Field description 01 Managers only Yes "
</nowiki>
The settings list is a tab separated values string for the following field form items:
<nowiki>
Name
Description
Visible
Editable
Label
param1
param2
param3
param4
param5
param6
param7
param8
param9
param10
</nowiki>
You can prepare a list of settings in a spreadsheet (each row a new set). When you select in the spreadsheet the cells of a settings set and paste it into the fixture file it will be pasted as a tab separated values string.


The content of the param items may differ between field types.
====Given I add a dataform with "DATAFORM_URL_STRING"====
Adds a dataform as teacher 1 in course 1 and displays the dataform.


You can include in the settings list only some of the form settings but the order should be preserved. For example, if you want to add a field with only name and description (the rest will be the default settings) you can add the following step:
====Then the dataform settings should match "FORM_DATA_STRING"====
<nowiki>
Validates dataform activity settings.
And I add a dataform field "checkbox" with "Field 01 Field description 01”
</nowiki>
====I add a dataform view "VIEWTYPE_STRING" with "SETTINGSLIST_STRING"====
* Adds a view of the specified type to the current dataform with the provided table data (usually Name).
* The step begins in the dataform's Manage | Views tab.


====I set view "VIEWNAME_STRING" as default====
====Given I add a test dataform====
* Sets a view as the default view of a dataform instance.
Adds a test dataform as teacher 1 in course 1 and displays the dataform.
* The step begins in the dataform's Manage | Views tab
* with the designated view (by name) already added.


====I add a dataform filter with "SETTINGSLIST_STRING"====
====Given I delete this dataform====
* Adds a filter with the specified data to the current dataform.  
Deletes the dataform.
* The step begins in the dataform's Manage | Filters tab.
 
====Given I go to manage dataform "TAB_NAME_STRING"====
Go to the specified manage tab of the current dataform.
 
====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).
 
====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).
 
====Given I set view "VIEW_NAME_STRING" as default view====
Sets a view as the default view of a dataform instance.
 
====Given I add a dataform filter with "FORM_DATA_STRING"====
Adds a filter with the specified data to the current dataform.
 
====Given I prepend "TEXT_STRING" to field "FIELD_STRING"====
Prepends text to the field's content.
 
====Given I apppend "TEXT_STRING" to field "FIELD_STRING"====
Appends text to the field's content.
 
====Given I set dataform field "FIELD_NAME_STRING" options to "OPTIONS_STRING"====
Sets a dataform field setting to the given content.
 
====Given I set the field "FIELD_NAME_STRING" to====
Sets field value to the specified text passed as PyStringNode.
 
====Given I fill textarea "FIELD_STRING" with "TEXT_STRING" ====
Fills a textarea with the specified text replacing \n with new lines.


====I add a dataform entry====
* Adds an entry without data to the current dataform.
* You should be in the dataform page, and the dataform should have a default view with submission options.===Available tests===
===Available tests===
===Available tests===
====Add dataform====
====Add dataform====

Revision as of 15:58, 17 March 2014


Unit tests

TBC

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

Alternately administrator can use the Dataform Acceptance testing interface from

Administration > Site administration > Plugins > Activity modules > Dataform > Acceptance testing

for testing particular Dataform features by name or tags.

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.

df-acceptance-testing.png

Available steps

Given I start afresh

Resets (truncates) all dataform tables to remove any records and reset sequences.

Given I start afresh with dataform "DATAFORM_NAME_STRING"

Starts afresh with a dataform activity 'Test dataform' in Course 1.

Given I go to dataform page "DATAFORM_URL_STRING"

Opens Dataform url.

Given I add a dataform with "DATAFORM_URL_STRING"

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

Then the dataform settings should match "FORM_DATA_STRING"

Validates dataform activity settings.

Given I add a test dataform

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

Given I delete this dataform

Deletes the dataform.

Given I go to manage dataform "TAB_NAME_STRING"

Go to the specified manage tab of the current dataform.

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

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

Given I set view "VIEW_NAME_STRING" as default view

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

Given I add a dataform filter with "FORM_DATA_STRING"

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

Given I prepend "TEXT_STRING" to field "FIELD_STRING"

Prepends text to the field's content.

Given I apppend "TEXT_STRING" to field "FIELD_STRING"

Appends text to the field's content.

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

Sets a dataform field setting to the given content.

Given I set the field "FIELD_NAME_STRING" to

Sets field value to the specified text passed as PyStringNode.

Given I fill textarea "FIELD_STRING" with "TEXT_STRING"

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

Available tests

Add dataform

Add fields

Add filters

Add views

Add entries with no fields

Add entries with all fields

Add entries with field checkbox

Add entries with field select

Add entries with field select multiple

Add entries with field text

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.