on 08-26-2015 8:11 AM
Hi All,
I am trying to implement QUnit testing for my UI5 app. As mentioned in some articles I have created my test.js file to write all the test cases, one qunit.html file for bootstrapping libraries including test.js and mycontroller.js files. All my functionalities are in mycontroller.js which I want to test.
Now my issue is, when I am trying to test the methods which are directly written inside other JS files, I am able to do that but when I am trying to test methods of controller file, its shows me method is undefined.
I suspect the reason is my controller has following structure.And when I am trying to access the method using "MyController.myMethod" the test.js file is not able to catch the method.
MyController.js
sap.ui.controller("MyController", {
myMethod: function(){}
}
test.js
QUnit.test( "Sample test", function( ) {
ok(MyController.myMethod, "Employee type Test Passed!" );
});
Can you please suggest a way how we can access methods of controller file?
Regards,
Anupriya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you loaded your controller in the test.js before you start with the Quint ? you can either do,
jQuery.sap.require("path-of-controller");
or the AMD style
sap.ui.require(["path/of/controller"],
function(MyController){
//Quint code
});
- Sakthivel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the response.
Yes I have already done that but its not able to access the method . As the structure of the controller file is
sap.ui.controller("MyController", {
myMethod: function(){}
}
And I am not able to directly access the method using name_of_controller.method_name().
In normal JS files, the structure will be something like this:
jQuery.sap.declare("file");
MyTestFile = {
myMethod: function(employeeID){
}}
In this case we can directly access method using dot operator.
But that is not happening in controller's case.
Regards,
Anupriya
User | Count |
---|---|
68 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.