Skip to Content
0

Question with qUnit setup in SAPUI5 application

Oct 31, 2016 at 09:09 PM

31

avatar image

I'm trying to implement unit testing within my SAPUI5 Application. I understand how to perform the unit tests --but I'm having difficulty in the initial setup in my SAP UI5 application. I believe the problem is how I'm attempting to load in the controller I want to test. I have a basic tree structure like so:

At this point, the next step would be setup the test.js. In that file, I need to reference the controller I'd like to test against. I figured I would need to load in the controller as a dependency, but I'm not following how to do so correctly. Below are my files test.js & initialTest.html. Can someone point me in the right direction in terms of setup?

sap.ui.require(["../Controller/Main.controller.js"],

 function(MyController){
     //Quint code
     test("hello test", function(assert) {
      assert.ok(1 == "1", "Passed!");
    });
});
   <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <title>QUnit Example</title>
      <link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.15.0.css">
          <script id="sap-ui-bootstrap"
                    src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js">
          </script>    
          <script src="//code.jquery.com/qunit/qunit-1.15.0.js"></script>
          <script src="tests.js"></script>
          <script src="/Controller/Main.controller.js"></script>          
          <script>
          </script>
    </head>
    <body>
      <div id="qunit"></div>
      <div id="qunit-fixture"></div>
    </body>
    </html>
filestructure.png (25.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers