There are a number of SmartForms testing tools on the market that let developers test their SmartForms. But in 4.7 there is something hidden away that is just dying to be played with. Like the developer’s best friend, the SmartObject Service Tester, there is now a tool that lets you automate testing of your SmartForms.
How to access it
To get to this hidden gem, go to the K2 Designer, click on the ‘Show’ link at the bottom of the page and in the pop-up click on ‘System’.
You will notice that the context browser in the designer now has some additional categories.
- Expand System
- Expand Forms
- Expand SmartForms Tester
- Click on ‘SmartForms Tester – Landing Page’
- Click on the ‘Runtime URL’ in the properties page
- The SmartForms Tester portal will load up and we can start to build a test case
SmartForms Tester portal
This is where we manage the automated testing of forms, from creating new tests to running existing ones.
K2 give us some examples of how to use the tester portal in the ‘Examples’ folder, or what they like to call ‘Suites’.
So let’s create a suite.
Creating a test suite
- Click on ‘Test Suites’
- A list of options will appear at the top
- Click on ‘New Suite’
- A pop-up window will appear. Enter the name of your suite. I am going to call mine ‘Annual Leave’
- Click on ‘Accept’
- Click on the ‘Refresh List’ button
- You will now see the suite you just created in the list
Creating a new test
- Click on the suite you just created
- The list options above will change
- Click on ‘New Test’
- This opens a new window where we can build a new test case
- In the SmartForm section, choose the view or form you want to test. In this case I am going to create a simple test for a view
- When you select a view or form, it appears in the top section of the testing form
- Below the name of the selected artefact are the actions. This is where we build the test script that the portal will execute for us
Creating the automated test script
- In the actions section you will see part of an action already selected
- Because I have chosen a view to test, the first drop-down has ‘View’ selected and the second has ‘Control’ selected
- From the third drop-down we can now choose a control on the view
- I am going to choose the picker control ‘pkrUsername’
- A fourth drop-down appears and should have ‘Change Value’ selected
- A text box is also available where a value can be entered. I am going to enter ‘sallport’
- When we execute this action, the tester will put ‘sallport’ into the picker control for you
- Click on ‘Add’ to add another action
- I am going to select the ‘calStartDate’ control and enter a date, and do the same for ‘calEndDate’
- I am going to add another action so it can select a leave type. I am going to enter ‘Paid leave’
- Last of all, I am going to select the ‘Button’ control and tell it to click the button
- That’s my simple test script: fill out the view and click the button to submit the data. I am ready to get the tester to run it for me
- Before I do that, click on the menu in the top left-hand corner and select ‘Save’
- The ‘Save Test’ pop-up will appear. Enter a name for the test, make sure the correct suite is selected and click on ‘OK’
Running the test
From the test designer we can either run the whole script or click one of the actions to test a particular line.
- I am going to run the whole script, so click on the ‘Run All’ button. The designer will then carry out the actions line by line
- A report is then displayed telling you whether it was successful or not
- The action lines will all be green, the data will be displayed in the view, and of course you can check the SmartObject that was used to save the data
- You can also run the test from the main testing portal by selecting the test from the suite and clicking on the ‘Run Test’ option
So that is a basic how-to for the SmartForms Tester. There are other options I haven’t covered, such as delayed actions, modifying variables, and assertions such as the total count of items in a list.
Conclusion
What is good about this tool is that it’s all built using SmartForms, so we are seeing some new controls that aren’t yet available in the SmartForms designer, such as the context menu and the action list, which is probably a more advanced list view. I hope these will be made available soon.
The second good thing is that the test data is available as SmartObjects, which means we can use them to build rich testing reports that also take business data into account.
It’s a great start, and hopefully it will be fleshed out in future updates, so that it would be possible to fill out the form, get a task and action it, all in one test case.