This document summarizes a presentation given by Nicholas C. Zakas on the evolution of YUI Test and introducing the new standalone version. Some key points:
- YUI Test was originally developed as a testing framework for YUI but inconsistencies arose between YUI 2.x and 3.x versions.
- A new standalone version was created to address these issues and allow YUI Test to be used without YUI dependencies. It provides a familiar syntax and API improvements.
- Additional related libraries were introduced, including a Selenium driver for browser automation and code coverage to identify untested code paths.
- Together these provide a complete JavaScript testing solution for continuous integration with features like Hudson integration and reporting
5. Automated Integration Testing
with YUI Test (Talk)
October 2009
YUI Test Debut
July 2007 (YUI 2.3.0)
Async Testing
TestReporter
XML and JSON Test Formats
December 2007 (YUI 2.4.0)
Mock Objects
Friendly Test Names
September 2009 (YUI 3.0.0)
Test-Driven Development
with YUI Test (Talk)
October 2008
YUI Test Debut
July 2007 (YUI 2.3.0)
Getting started with
YUI Test (YUIBlog)
December 2008
Writing effective tests
(YUIBlog)
January 2009
Automation Hooks
JUnit XML and TAP Formats
April 2010 (YUI 3.1.0)
ZOMG!!!
Today
Yeti Released
August 2010
24. Friendlier Test Names
var testCase = new YUITest.TestCase({
name: "My Test Case",
"This should be a test": function(){
//this is a test in YUI Test for YUI 3.x
},
"As is this one": function(){
//this is not a test in YUI Test for YUI 3.x
//but is in YUI Test Standalone 1.0.0
}
});
25. Counting Asserts
var testCase = new YUITest.TestCase({
name: "My Test Case",
"This should be a test": function(){
//this test passes in YUI Test for YUI 3.x
//but fails in YUI Test Standalone 1.0.0
}
});
26. Beyond _should
var testCase = new YUITest.TestCase({
name: "My Test Case",
_should: { //old
"Another test": "Error message"
},
"Another test": function(){ //new
someFunction();
}
});
27. Beyond _should
var testCase = new YUITest.TestCase({
name: "My Test Case",
"Another test": function(){ //new
YUITest.Assert.throwsError("Error message",
someFunction);
}
});
28. What about the YUI 2.x and 3.x
versions?
YUI Test Standalone becomes the
core implementation of both
42. Test Pages
var testCase = new YUITest.TestCase({
name: "My Test Case",
//...
});
YUITest.TestRunner.add(testCase);
YUITest.TestRunner.run();
Test pages must automatically begin
running tests without additional interaction
43. Command Line
Usage: java -jar yuitest-selenium-driver-x.y.z.jar [options] [test files]
Global Options
-h, --help Displays this information.
--browsers <browsers> Run tests in these browsers (comma-delimited).
--conf <file> Load options from <file>.
--coveragedir <dir> Output coverage files to <dir>.
--erroronfail Indicates that a test failure should cause
an error to be reported to the console.
--host <host> Use the Selenium host <host>.
--port <port> Use <port> port on the Selenium host.
--resultsdir <dir> Output test result files to <dir>.
--silent Don't output test results to the console.
--tests <file> Loads test info from <file>.
-v, --verbose Display informational messages and warnings.
45. Tests File
<?xml version="1.0"?>
<yuitest>
<tests base="http://www.example.com/tests/" timeout="10000">
<url>test_core</url>
<url timeout="30000">test_util</url>
<url>test_ui</url>
</tests>
</yuitest>
Easiest way to specify multiple tests to
execute on the same host machine
54. Code can have multiple paths
function doSomething(){
if (condition){
doSomethingElse();
} else {
doAThirdThing();
}
}
The goal of unit testing is to exercise each path
The goal of code coverage is to identify if you did
60. Command Line
Usage: java -jar yuitest-coverage-x.y.z.jar [options] [file|dir]
Global Options
-h, --help Displays this information.
--charset <charset> Read the input file using <charset>.
-d, --dir Input and output (-o) are both directories.
-v, --verbose Display informational messages and warnings.
-o <file|dir> Place the output into <file|dir>. Defaults to
stdout.
65. Command Line
Usage: java -jar yuitest-coverage-report-x.y.z.jar [options] [file]
Global Options
-h, --help Displays this information.
--format <format> Output reports in <format>. Defaults to HTML.
-v, --verbose Display informational messages and warnings.
-o <file|dir> Place the output into <file|dir>.