Note: You are currently viewing documentation for Moodle 3.11. 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
 
(10 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
===Available tests===
====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.
==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===
 
====Activity====
Alternately administrator can use the Dataform Acceptance testing interface from
=====Basics=====
 
*Adds a Dataform activity to a course.
''Administration > Site administration > Plugins > Activity modules > Dataform > Acceptance testing''
*Adds all standard fields with default settings.
 
*Adds all standard views with default settings.
for testing particular Dataform features by name or tags.
*Submits a new entry with content in the text field in each view.
 
*Sets quick filter
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.
**Sets quick per page and navigates between pages with the paging bar
 
**Filters entries with the quick search
[[File:df-acceptance-testing.png]]
**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=====
====field====
=====field checkbox=====
=====field duration=====
=====field file=====
=====field number=====
=====field picture=====
=====field radiobutton=====
=====field select=====
=====field selectmulti=====
=====field text=====
=====field textarea=====
=====field time=====
=====field url=====
====view====
=====view all submission buttons=====
*Scenario: Submit entries with different submission buttons
*Scenario: Submission should not be allowed when no submission buttons enabled
=====view aligned=====
=====view csv=====
=====view grid=====
=====view interval=====
=====view rss=====
=====view tabular=====
===Available steps===
===Available steps===
====I start afresh====
====Given I start afresh with dataform "DATAFORM_NAME_STRING"====
* Resets (truncates) all dataform tables to remove any records and reset sequences.
Prepares  a fresh environment with the following components and a dataform activity 'Test dataform' in Course 1.
* 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.
Course:
====I add a test dataform====
| fullname | shortname | category
* Adds a test dataform as teacher 1 in course 1 and displays the dataform.  
| Course 1 | C1 | 0
* The step begins in a new test site.
====I delete this dataform====
Users:
* Deletes the dataform.
| username | firstname | lastname | email
* This step begins inside the designated dataform.
| teacher1 | Teacher | 1 | teacher1@asd.com
* Useful at the end of standalone scenarios for cleanup.
| assistant1 | Assistant | 1 | assistant1@asd.com
====I go to manage dataform "TABNAME_STRING"====
| student1 | Student | 1 | student1@asd.com
* Goes to the specified manage tab of the current dataform.  
| student2 | Student | 2 | student2@asd.com
* The step begins from the dataform's course page.
| student3 | Student | 3 | student3@asd.com


Example:
Enrollments:
  <nowiki>
  | user | course | role
  And I go to manage dataform “filters”
| teacher1 | C1 | editingteacher
</nowiki>
  | assistant1 | C1 | teacher
====I add a dataform field "FIELDTYPE_STRING" with "SETTINGSLIST_STRING"====
| student1 | C1 | student
* Adds a field of the specified type to the current dataform with the provided table data (usually Name).
| student2 | C1 | student
* The step begins from the dataform's course page.
Groups:
| name    | description | course | idnumber |
| Group 1 | Anything    | C1 | G1  |
| Group 2 | Anything    | C1 | G2  |


'''Example''':
Group members:
  <nowiki>
  | user    | group  |
And I add a dataform field "checkbox" with "Field 01 Field description 01 Managers only Yes "
| student1 | G1 |       
</nowiki>
  | student2 | G2 |       
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.
It also resets (truncates) all Dataform tables to remove any records and reset sequences.


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:
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.
<nowiki>
====Given I go to dataform page "DATAFORM_URL_STRING"====
And I add a dataform field "checkbox" with "Field 01 Field description 01”
Opens Dataform url.
</nowiki>
====Given I add a dataform with "DATAFORM_URL_STRING"====
====I add a dataform view "VIEWTYPE_STRING" with "SETTINGSLIST_STRING"====
Adds a dataform as teacher 1 in course 1 and displays the dataform.
* Adds a view of the specified type to the current dataform with the provided table data (usually Name).  
====Then the dataform settings should match "FORM_DATA_STRING"====
* The step begins in the dataform's Manage | Views tab.
Validates dataform activity settings.
 
====Given I add a test dataform====
====I set view "VIEWNAME_STRING" as default====
Adds a test dataform as teacher 1 in course 1 and displays the dataform.
* Sets a view as the default view of a dataform instance.  
====Given I delete this dataform====
* The step begins in the dataform's Manage | Views tab
Deletes the dataform.
* with the designated view (by name) already added.
====Given I go to manage dataform "TAB_NAME_STRING"====
 
Go to the specified manage tab of the current dataform.
====I add a dataform filter with "SETTINGSLIST_STRING"====
====Given I add a dataform field "FIELD_TYPE_STRING" with "FORM_DATA_STRING"====
* Adds a filter with the specified data to the current dataform.  
Adds a field of the specified type to the current dataform with the provided table data (usually Name).
* The step begins in the dataform's Manage | Filters tab.
====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).
====I add a dataform entry====
====Given I set view "VIEW_NAME_STRING" as default view====
* Adds an entry without data to the current dataform.
Sets a view as the default view of a dataform instance.
* You should be in the dataform page, and the dataform should have a default view with submission options.===Available tests===
====Given I add a dataform filter with "FORM_DATA_STRING"====
===Available tests===
Adds a filter with the specified data to the current dataform.
====Add dataform====
====Given I prepend "TEXT_STRING" to field "FIELD_STRING"====
====Add fields====
Prepends text to the field's content.
====Add filters====
====Given I apppend "TEXT_STRING" to field "FIELD_STRING"====
====Add views====
Appends text to the field's content.
====Add entries with no fields====
====Given I set dataform field "FIELD_NAME_STRING" options to "OPTIONS_STRING"====
====Add entries with all fields====
Sets a dataform field setting to the given content.
====Add entries with field checkbox====
====Given I set the field "FIELD_NAME_STRING" to====
====Add entries with field select====
Sets field value to the specified text passed as PyStringNode.
====Add entries with field select multiple====
====Given I fill textarea "FIELD_STRING" with "TEXT_STRING" ====
====Add entries with field text====
Fills a textarea with the specified text replacing \n with new lines.
===Step values===
====FORM_DATA_STRING====
==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 22:53, 13 April 2014


Unit tests

Available tests

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.

Acceptance tests

Available features

Activity

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

field

field checkbox
field duration
field file
field number
field picture
field radiobutton
field select
field selectmulti
field text
field textarea
field time
field url

view

view all submission buttons
  • Scenario: Submit entries with different submission buttons
  • Scenario: Submission should not be allowed when no submission buttons enabled
view aligned
view csv
view grid
view interval
view rss
view tabular

Available steps

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

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.

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.