Creating Unit Tests for a New Module

  1. Create a package in NetBeans under Test Packages such as specs.<yourModule>
  2. In this package, create a new javascript spec file such as ControllerSpec.js and a .html file to run your tests such as pharmacy-tests.html
  3. Your .html file should look similar to the file shown below
  4. Add a link to your .html file in test/run-tests.html under Module Tests such as <li><a=href="specs/pharmacy/pharmacy-tests.html>Pharmacy</a></li>
  5. NOTE: Change the library name, if you're working with sencha touch.

 

<html>
    <head>
        <title id="page-title">Module Tester</title>
        <link rel="stylesheet" type="text/css" href="../../lib/jasmine-1.1.0/jasmine.css">
        <script type="text/javascript" src="../../../src/lib/extjs/ext-all-debug.js"></script>
        <script type="text/javascript" src="../../lib/jasmine-1.1.0/jasmine.js"></script>
        <script type="text/javascript" src="../../lib/jasmine-1.1.0/jasmine-html.js"></script>
        <!-- include specs here -->
        <script type="text/javascript" src="yourSpecFile.js"></script>
        <!-- load application here -->
        <script type="text/javascript">
            Ext.Loader.setConfig({
                enabled: true
            });
            Ext.require('Ext.app.Application');
            var Application = null;
            Ext.onReady(function() {
                Application = Ext.create('Ext.app.Application', {
                    //fill in details for your module
                    name: 'RaxaEmr.module',
                    appFolder: '../../../src/moduleName/app',
                    controllers: [
                        'YourController'
                    ],
                    launch: function() {
                        //include the tests in the test.html head
                        jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
                        jasmine.getEnv().execute();
                    }
                });
            });
        </script>
    </head>
    <body>
    </body>
</html>

 

Â