Automated testing of Adaptive Forms using Calvin SDK
Calvin SDK is a utility API for Adaptive Forms developers to test Adaptive Forms. Calvin SDK is built on top of the Hobbes.js testing framework. Calvin SDK is available with AEM Forms 6.3 onwards.
In this tutorial, you will create the following:
Download and Install the Assets using Package ManagerThe package contains sample scripts and several Adaptive Forms.These Adaptive Forms are built using AEM Forms 6.3 version. It is recommended to create new forms specific to your version of AEM Forms if you are testing this on AEM Forms 6.4 or higher. The sample scripts demonstrate various Calvin SDK API’s available to test Adaptive Forms. The general steps for testing AEM Adaptive Forms are:
The sample scripts in the package demonstrate all the above actions.
Let’s explore the code of mortgageForm.js
var mortgageFormTS = new hobs.TestSuite("Mortgage Form Test", {
path: '/etc/clientlibs/testingAFUsingCalvinSDK/mortgageForm.js',
register: true
})
The code above creates a new Test Suite.
Mortgage Form Test
'.true
', makes the Test Suite available in the testing UI..addTestCase(new hobs.TestCase("Calculate amount to borrow")
// navigate to the mortgage form which is to be tested
.navigateTo("/content/forms/af/cal/mortgageform.html?wcmmode=disabled")
.asserts.isTrue(function () {
return calvin.isFormLoaded()
})
If your are testing this capability on AEM Forms 6.4 or above, please create a new Adaptive Form and use it to do your testing.Using the Adaptive Form provided with the package is not recommended.
Test cases can be added to test suite to be executed against an adaptive form.
addTestCase
method of TestSuite object.addTestCase
method takes an TestCase Object as a parameter.hobs.TestCase(..)
method.navigateTo
, asserts.isTrue
can be added as actions to the test case.OpenthetestsuiteExpand the Test Suite and run the tests. If everything runs successfully, you will see the following output.
As part of the sample package there are three additional test suites. You can try them by including the appropriate files in the js.txt file of the clientlibrary as shown below:
#base=.
scriptingTest.js
validationTest.js
prefillTest.js
mortgageForm.js