Shared by eszpee
a példakód végefele kezd kurva jó lenni
John Resig and Jan Odvarko have announced something pretty darn cool, FireUnit.
FireUnit provides a simple JavaScript API for doing simple test logging and viewing within a new tab of Firebug.
The example given shows the API nicely:
JAVASCRIPT:
-
-
// Simple true-like/false-like testing
-
fireunit.ok( true, "I'm going to pass!" );
-
fireunit.ok( false, "I'm going to fail!" );
-
-
// Compare two strings - shows a diff of the
-
// results if they're different
-
fireunit.compare(
-
"The lazy fox jumped over the log.",
-
"The lazy brown fox jumped the log.",
-
"Are these two strings the same?"
-
);
-
-
// Compare a string using a regular expression
-
fireunit.reCompare(
-
/The .* fox jumped the log./,
-
"The lazy brown fox jumped the log.",
-
"Compare a string using a RegExp."
-
);
-
-
// Display the total results
-
fireunit.testDone();
-
-
// -- browser events
-
-
// You can also simulate browser events
-
var input = document.getElementsByTagName("input")[0];
-
fireunit.mouseDown( input );
-
fireunit.click( input );
-
fireunit.focus( input );
-
fireunit.key( input, "a" );
-
-
// -- Run batches
-
-
// Or run multiple pages of tests:
-
fireunit.runTests("test2.html", "test3.html");
-
-
// Place at the end of every test file in order to continue
-
fireunit.testDone();
-
Utolsó kommentek