Tags:
create new tag
, view all tags

JSUnitContrib

JSUnit JavaScript unit testing framework.

Usage

After installing, include the core js file with:
<script language="javascript" src="%PUBURL%/%TWIKIWEB%/JSUnitContrib/app/jsUnitCore.js"></script>

Example

Adapted example from the site:

Suppose we want to write a test for a function called multiplyAndAddFive(value1, value2) which multiplies value1 and value2 together, adds five, and returns the result. Also suppose that this function lives in a file called sample_script_to_test. Assume that if non-numeric values are passed in, the function should return null. A suitable Test Page would look like the following:

<html>
<head>
<title>Test Page for multiplyAndAddFive(value1, value2)</title>
<script language="javascript" src="%PUBURL%/%TWIKIWEB%/JSUnitContrib/app/jsUnitCore.js"></script>
<script language="javascript" src="%PUBURL%/%TWIKIWEB%/JSUnitContrib/sample_script_to_test.js"></script>
</head>
<body>
<script language="javascript">
    function testWithValidArgs() {
        assertEquals("2 times 3 plus 5 is 11", 11, multiplyAndAddFive(2, 3));
        assertEquals("Should work with negative numbers", -15, multiplyAndAddFive(-4, 5));
    }
    function testWithInvalidArgs() {
        assertNull("A null argument should result in null", multiplyAndAddFive(2, null));
        assertNull("A string argument should result in null", multiplyAndAddFive(2, "a string"));
    }
    function testStrictReturnType() {
        assertNotEquals("Should return a number, not a string", "11", multiplyAndAddFive(2, 3));
    }
    function testWithUndefinedValue() {
        assertNull("An undefined argument should result in null", multiplyAndAddFive(2, JSUNIT_UNDEFINED_VALUE));
    }
</script>
*[[%PUBURL%/%TWIKIWEB%/JSUnitContrib/testRunner.html?testpage=%SCRIPTURL{"view"}%/%TWIKIWEB%/JSUnitContrib][Run test]]*
</body>
</html>

If installed this will result in:

Run test

Documentation

See: http://www.jsunit.net/documentation/

Settings

  • Set SHORTDESCRIPTION = JSUnit JavaScript unit testing framework
  • Set STUB = TWiki::Contrib::JSUnitContrib

Installation Instructions

  • Download the ZIP file from the Plugin web (see below)
  • Unzip JSUnitContrib.zip in your ($TWIKI_ROOT) directory. Content:
    File: Description:
    data/TWiki/JSUnitContrib.txt  
    lib/TWiki/Contrib/JSUnitContrib.pm  
    pub/TWiki/JSUnitContrib/sample_script_to_test.js  
    pub/TWiki/JSUnitContrib/app/css/jsUnitStyle.css  
    pub/TWiki/JSUnitContrib/app/css/readme  
    pub/TWiki/JSUnitContrib/app/emptyPage.html  
    pub/TWiki/JSUnitContrib/app/jsUnitCore.js  
    pub/TWiki/JSUnitContrib/app/jsUnitMockTimeout.js  
    pub/TWiki/JSUnitContrib/app/jsUnitTestManager.js  
    pub/TWiki/JSUnitContrib/app/jsUnitTestSuite.js  
    pub/TWiki/JSUnitContrib/app/jsUnitTracer.js  
    pub/TWiki/JSUnitContrib/app/jsUnitVersionCheck.js  
    pub/TWiki/JSUnitContrib/app/main-counts-errors.html  
    pub/TWiki/JSUnitContrib/app/main-counts-failures.html  
    pub/TWiki/JSUnitContrib/app/main-counts-runs.html  
    pub/TWiki/JSUnitContrib/app/main-counts.html  
    pub/TWiki/JSUnitContrib/app/main-data.html  
    pub/TWiki/JSUnitContrib/app/main-errors.html  
    pub/TWiki/JSUnitContrib/app/main-frame.html  
    pub/TWiki/JSUnitContrib/app/main-loader.html  
    pub/TWiki/JSUnitContrib/app/main-progress.html  
    pub/TWiki/JSUnitContrib/app/main-results.html  
    pub/TWiki/JSUnitContrib/app/main-status.html  
    pub/TWiki/JSUnitContrib/app/testContainer.html  
    pub/TWiki/JSUnitContrib/app/testContainerController.html  
    pub/TWiki/JSUnitContrib/app/xbDebug.js  
    pub/TWiki/JSUnitContrib/bin/mac/readme.txt  
    pub/TWiki/JSUnitContrib/bin/mac/start-firefox.scpt  
    pub/TWiki/JSUnitContrib/bin/mac/start-firefox.sh  
    pub/TWiki/JSUnitContrib/bin/mac/start-safari.scpt  
    pub/TWiki/JSUnitContrib/bin/mac/start-safari.sh  
    pub/TWiki/JSUnitContrib/bin/mac/stop-firefox.scpt  
    pub/TWiki/JSUnitContrib/bin/mac/stop-firefox.sh  
    pub/TWiki/JSUnitContrib/bin/mac/stop-safari.scpt  
    pub/TWiki/JSUnitContrib/bin/mac/stop-safari.sh  
    pub/TWiki/JSUnitContrib/bin/unix/start-firefox.sh  
    pub/TWiki/JSUnitContrib/bin/unix/stop-firefox.sh  
    pub/TWiki/JSUnitContrib/build.xml  
    pub/TWiki/JSUnitContrib/changelog.txt  
    pub/TWiki/JSUnitContrib/css/jsUnitStyle.css  
    pub/TWiki/JSUnitContrib/images/green.gif  
    pub/TWiki/JSUnitContrib/images/logo_jsunit.gif  
    pub/TWiki/JSUnitContrib/images/powerby-transparent.gif  
    pub/TWiki/JSUnitContrib/images/red.gif  
    pub/TWiki/JSUnitContrib/index.jsp  
    pub/TWiki/JSUnitContrib/jsunit.properties.sample  
    pub/TWiki/JSUnitContrib/licenses/gpl-2.txt  
    pub/TWiki/JSUnitContrib/licenses/index.html  
    pub/TWiki/JSUnitContrib/licenses/JDOM_license.txt  
    pub/TWiki/JSUnitContrib/licenses/Jetty_license.html  
    pub/TWiki/JSUnitContrib/licenses/lgpl-2.1.txt  
    pub/TWiki/JSUnitContrib/licenses/MPL-1.1.txt  
    pub/TWiki/JSUnitContrib/licenses/mpl-tri-license-c.txt  
    pub/TWiki/JSUnitContrib/licenses/mpl-tri-license-html.txt  
    pub/TWiki/JSUnitContrib/logging.properties  
    pub/TWiki/JSUnitContrib/readme.txt  
    pub/TWiki/JSUnitContrib/testRunner.html  
    pub/TWiki/JSUnitContrib/tests/data/data.html  
    pub/TWiki/JSUnitContrib/tests/data/staff.css  
    pub/TWiki/JSUnitContrib/tests/data/staff.dtd  
    pub/TWiki/JSUnitContrib/tests/data/staff.xml  
    pub/TWiki/JSUnitContrib/tests/jsUnitAssertionTests.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitFrameworkUtilityTests.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitMockTimeoutTest.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitOnLoadTests.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitRestoredHTMLDivTests.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitSetUpTearDownTests.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitTestLoadData.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitTestLoadStaff.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitTestSetUpPages.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitTestSetUpPagesSuite.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitTestSuite.html  
    pub/TWiki/JSUnitContrib/tests/jsUnitUtilityTests.html  

  • Optionally, run JSUnitContrib_installer to automatically check and install other TWiki modules that this module depends on. You can also do this step manually.
  • Alternatively, manually make sure the dependencies listed in the table below are resolved. None

Contrib Info

Authors: TWiki:Main.ArthurClemens
Copyright ©: Copyright (C) 2001-6 Edward Hieatt, edward@jsunitPLEASENOSPAM.net. Packaged for TWiki 2006 by Arthur Clemens. Directory java removed to reduce package size.
License: GPL, GNU Library or Lesser General Public License (LGPL), Mozilla Public License 1.1 (MPL 1.1)
Dependencies: None
28 Oct 2006 Version jsunit2.2alpha11
Home: http://TWiki.org/cgi-bin/view/Plugins/JSUnitContrib
Feedback: http://TWiki.org/cgi-bin/view/Plugins/JSUnitContribDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/JSUnitContribAppraisal

Related Topics: TWikiPreferences

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 JSUnitContrib.md5 r4 r3 r2 r1 manage 0.2 K 2008-12-12 - 11:40 SopanShewale checksum file , Uploaded as a part of Release Process
Compressed Zip archivetgz JSUnitContrib.tgz r4 r3 r2 r1 manage 68.9 K 2008-12-12 - 11:39 SopanShewale See JSUnitContrib for details. Untar and run the installer script, Uploaded as a part of Release Process
Compressed Zip archivezip JSUnitContrib.zip r4 r3 r2 r1 manage 104.7 K 2008-12-12 - 11:39 SopanShewale See JSUnitContrib for details. Unzip and run the installer script , Uploaded as a part of Release Process
Unknown file formatEXT JSUnitContrib_installer r3 r2 r1 manage 7.1 K 2008-12-12 - 11:40 SopanShewale Installer Script, Uploaded as a part of Release Process
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2008-12-12 - SopanShewale
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.