Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Lesson 2: Writing, testing, and debugging JavaScript CHAPTER 3 91


FIGURE 3-4 he NuGet search results containing QUnit For ASP.NET MVCT

Next, add a default.html page by right-clicking the project node (in the Solution Explorer
window) and click Add; choose HTML Page. Name the file default.html and click OK. Make
the default.html file your startup page by right-clicking the default.html file and choosing Set
As Start Page. Modify the default.html file to look like the following example, in which the
inserted lines are in bold:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="Content/qunit.css" />
<script type="text/javascript" src="Scripts/qunit.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>

The QUnit setup is done, but in this file, you still need to add references to the code that
will be tested and the actual tests. Your code and your tests should be in separate files, so you
will be adding at least two references. Navigating to Debug and choosing Start Debugging
causes the QUnit summary screen to be displayed, as shown in Figure 3-5.
Free download pdf