Jasmine

Introduction

jWebSocket is a framework/webserver with a lot of available ready to use application features, from data storage to channels or chat plug-ins, community and commercial applications.
Testing is always a required phase during software development, from small functions to final features tests. The following documentation covers the jWebSocket framework automated functional testing support, intended for backend application developers.

The jasmine framework

Jasmine is a testing framework for JavaScript environments. Because WebSocket based apps uses client to server architecture, were the GUI components call backend services features, Jasmine is ideal to automated test the jWebSocket server features.

Using the jWebSocket Jasmine tests manager

jWebSocket developers created a Jasmine based tests manager to easily register and execute new test cases for existing and future plug-ins features. See “web/test” directory of the jWebSocket Community Edition web files.

Creating tests for a custom plug-in require the following steps:

  1. Create the test plug-in object in the "jws.tests" namespace:
  2. // see web/test/js/jwsReporting.js for full example
    
    jws.tests.PlugInName = {
      title: "Test plug-in name",
      description: "Test plug-in description",
      category: "Plug-in category",
      priority: 30,  //execution priority on category, default 100
      enabled: true, //default true   
     
      testCase1: function(){…},
      testCase2: function(){…},
    
      runSpecs: function() {
        this.testCase1();
        this.testCase1();
      }
    }
  3. Include the JavaScript file that contains the created test plug-in in the "runTests.htm" file:
  4. <!-- 
    	#################################
    	#  INCLUDE YOUR TEST FILES HERE	#
    	#################################
    -->
    <!-- shared test specs for opening and closing connections->
    <script type="text/javascript" src="js/jwsSharedTests.js"></script>
    <!-- your test plugin -->
    <script type="text/javascript" src="js/yourTestPlugIn.js"></script>
  5. Open "runtTests.htm" file in a web browser, select you test plug-ins and "Run selected tests":

     

Copyright © 2013 Innotrade GmbH. All rights reserved.