QUnit Jump Start PRO

The QUnit framework allows us to develop unit tests for code developed in JavaScript. The following video clip overviews a simple demo for using this framework.

The following is the code sample this video clip overviews. The QUnit website includes detailed documentation and code samples for using this framework.

<!DOCTYPE html>
<html>
<head>
    <title>QUnit Demo</title>
    <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
    <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
    <script src="mylib.js"></script>
</head>
<body>
    <div id="qunit"></div>
    <div id="qunit-fixture"></div>
    <script type="text/javascript">
    test("the sum() function unit test",
        function()
        {
            var numA = 3;
            var numB = 4;
            var result = sum(numA,numB);
            equal( result, 7, "sum of 3 and 4 succeeds" );
            numA = 9999999999999999999999999999999999999999;
            numB = 1;
            result = sum(numA,numB);
            equal(result,10000000000000000000000000000000000000000,"sum of 9999999999999999999999999999999999999999 and 1 succeeds");
        }
    );
    test("the biggest() function unit test",
            function()
            {
                equal( biggest(2,5), 5, "getting that 5 is bigger than 2 succeeds" );
                equal( biggest(9,5), 9, "getting that 9 is bigger than 5 succeeds" );
                equal( biggest(9,5), 9, "getting that 9 is bigger than 5 succeeds" );
            }
    );
    </script>
</body>
</html>

You can find the community version of the QUnit Basics course available for free personal usage at http://abelski.lifemichael.com.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences