There are a number of Smartform testing tools currently on the market to allow developers to 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 SmartObject Service Tester, there is now a tool that will allow you to automate testing of your Smartforms.
How to access it
To access this hidden gem of a tool, go to the K2 Designer and click on ‘show’ link at the bottom of the page and in the pop up click on System.
How you will notice in the context browser for the designer there is now some additional categories.
- Expand System
- Expand Forms
- Expand Smartform tester
- Click on ‘SmartForms Tester – Landing Page’
- Click on the ‘Runtime URL’ in the properties page
- The Smartform Tester Portal will now load up and we can start to build a test case
SmartForms Tester Portal
This is where we can manage the automating of the forms from creating new tests to running existing ones.
K2 do give us some examples of how to use the tester portal in the ‘Examples’ folder or what they like to call ‘Suites’
So lets 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 in the name of what your suite is going to be called. I am going to call mine ‘Annual Leave’
- Click on ‘Accept’
- Click on ‘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 will open a new window, from where we can build a new test case
- Click on in the Smartform section and choose the View or Smartform you want to test. In this case i am going to create a simple test to test a view
- When you select a view/form it will then appear in the in top section of the testing form
- Below the name of the select artifact
- Is the actions this where will build the test script that the portal will execute for us
Creating the automated test script
- In the actions section, you will see there part of a action already selected
- Because i have chosen a view to test. The first drop down list has ‘View’ selected. The 2nd drop down list has ‘Control’ selected.
- From the 3rd drop down list we can now choose a control on the view
- I am going to choose the picker control ‘pkrUsername’.
- A 4th drop down list appears and should have ‘Change Value’ selected
- Text box is also available, where a value can be entered. I am going to enter in ‘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 in a date and i am going to the same with for ‘calEndDate’
- I am going to add another action so it can ‘select’ a leave type. I am going to enter in ‘Paid leave’
- Last of all i am going to select the ‘Button’ control and tell it to click the button.
- Now that my simple test script of filling out the view and clicking on the button to submit the data. I am ready to get the tester to run it for me.
- But before I do that just click on the in the top left hand corner and select ‘Save’ from the context menu
- ‘Save Test’ pop window will appear, enter in a name for test and 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 by clicking one of the actions we can test a particular line.
- I am going to run the whole script, so click on ‘Run All’ button. The designer will then carry out the actions line by line.
- A report will then be displayed telling you if it was successful or not.
- The actions line will also all be green and of course the data inserted into the view will be displayed and of course you can check the SmartObject that was used to save the data.
- You can also run the test from main testing portal , by selecting the test from the suite and then clicking on ‘Run Test’ option
So this is a basic how to use the Smartform tester, and there are other options that I have not covered such as delayed actions and modifying variables and assertions such total count of items in a list etc..
Demo forms can be downloaded from here
What is good about this tool it’s all built using Smartforms, so not only are we seeing some new controls that are not made available yet to in the Smartform designer, such as the context menu, the action list with is probably a more advanced list view. I hope these will made available soon.
The 2nd good thing about this is that the test data is available as SmartObjects which mean we can then use these to build rich testing reports that also take into account business data.
It’s great start to something that will hopefully be fleshed out with further updates in the future. So it would be possible to fill out the form, get a task and action it, all in one test case.