You can create test scripts and use them in Kony Visualizer from Kony Visualizer SP3 GA onwards. Even though testing scripts were supported by Kony earlier, they were never supported in Kony Visualizer directly. In previous releases of Kony Visualizer, you could create scripts and place them in the Other Resources folder in the Project View of Kony Visualizer.
The new Test Resources folder in Kony Visualizer allows you to create test scripts for specific channels such as Mobile, Tablet, Desktop Web etc. The new feature also allows you to use multiple testing frameworks. For each one of the testing framework, the test resources folder has separate child folders for each channel. This allows you to easily identify the script types and use the ones which are appropriate for the channel you are testing. You can now manage your scripts directly from the Kony Visualizer UI.
The Test Resources folder contains a TestNG folder by default. This folder further contains default channel folders.
You can add another testing framework, Jasmine, by editing the projectproperties.json file located in your project folder (<workspace><project>/projectProperties.json
). Enter the following key-value pair in the projectproperties.json file and the Jasmine testing framework will be added to the Test Resources folder in Kony Visualizer.
"enableJasmineAutomation": "true"
Once you refresh the TestResources folder, the Jasmine folder will be listed.
You can create a new test script specific to the channel by placing a test script within the channel's sub folder. If the file is created under the TestNG sub directory, the new file contains an empty shell with the basic TestNG test script. When you make edits to a script, it is saved when the project is saved.
The following sections in the document describe about creating and executing testscripts for TestNG and Jasmine test frameworks.
Create a test script for TestNG
Execute test script for TestNG
Create a test script for Jasmine
Execute test script for Jasmine
To create a new test script in TestNG folder, do the following:
To execute test scripts in TestNG, do the following:
Open Visualizer.
In the File menu, navigate to Product > Build.
Build the app for the channel you are testing the script.
Run your app on the simulator.
Copy the workspace location of your test scripts.
Open Command Prompt on your system.
Run the following command
ant build.xml/Project name/<location_of_scripts_in_workspace>
Your test scripts are executed.
To create a new test script in the Jasmine folder, do the following:
Note: It is not mandatory to create the new file. You can write all your automation scripts in the automationStartup.js file, that is auto generated. You must create a new file only when you want to segregate test scripts for each of your app flow.
describe("sample", function() { beforeEach(function() { //gets executed once before each spec in the describe }); afterEach(function() { //gets executed once after each spec. }); it("sample_testCase", async function() { kony.automation.button.click(["Form1", "Button0ec5b6258f1504e"]); }); });
To execute the script, enter the code in the following format, in the automationStartup.js file.
require(["testScripts/sample-suite"], //prepending testScripts function() { jasmine.getEnv().execute(); });
You must prepend each file that is being required with a key word testScripts. In the require callback, you must appropriately call the jasmine execution. If you want to require multiple files, jasmine execution must be called in the last required file.
Important: The name customReporter.js file is reserved for the Jasmine test scripts common js file. If you name any of your test scripts with customReporter.js, testing feature as explained in this section will not work. Ensure that you give unique test javascript file names across channels.
With the customReporter.js test script, you can access all Kony APIs and methods used in Kony Visualizer . In any test script that you create on your own in the common folder, you can only access the kony.print API. Ensure that you do not modify anything in the customReporter.js. You can write your code in the jasmine callbacks.
To execute test scripts in Jasmine, do the following:
From the File menu, go to Product > Build.
Build the app for the channel that you are testing the script, in debug mode.
Run your app on the target simulator or device.
Although the system and the target device are connected on the same network, you may have trouble executing your test script when the app uses an inaccessible IP address. To modify the IP address, follow these steps:
Note: In Jasmine, the jasmine.DEFAULT_TIMEOUT_INTERVAL
property is not considered for Native channels. This is because the Async/Await command support in Jasmine is only applicable for the Responsive Web channel, but not for Native. However, if you specify an Async/Await command as part of your test script for Native channels, your script still works as expected.
For more information about APIs and automation in Kony, click here.
To debug an Android application while using Jasmine test scripts, follow these steps.
“enableJasmineJSDebuggingForAndroid” : "true"
Note: The chrome devtools URL uses only the 9222 port while using Jasmine test scripts.
Copyright © 2013 Kony, Inc. All rights reserved. |