We have 500+ JsUnit tests on my current project. These tests are a very valuable asset to the team. Their true value is not realized unless they are integrated into our automated build process.
[Test]public void RunJSUnitTests(){ string testDirectory = ConfigurationManager.AppSettings["JsTestDir"]; ITestFileReader reader = new ExcludeTestFileReader("jsunit", new SuffixTestFileReader("tests.htm", new TestFileReader(testDirectory))); Assert.IsTrue(new JsUnitTestRunner(reader).Run());}
This NUnit test runs all of our JsUnit tests.ITestFileReader is the most crucial part of the above code. ITestFileReader is the type responsible for feeding JsUnit test files to the JsUnitTestRunner. There are currently three types of ITestFileReaders:TestFileReader
Returns each file in the directory, including subdirectories, with each call to GetNextTestFile. Expects the name of a directory as its parameter.
SuffixTestFileReader
Decorator for aITestFileReaderthat ensures all test files end with a specific postfix. Expects a sufÅfix string and aITestFileReader.
ExcludeTestFileReader
Decorator for aITestFileReaderthat ensure only files that do not match the exclude string are returned from theGetNextTestFile.
When new JsUnitTestRunner(reader).Run() is executed a new JsUnit suite is generated and saved to all_tests.html. WatiN is then used to execute the suite in JsUnit’s test runner.Add the following to your App.config so JsUnitTestRunner can find your JsUnit installation. InstallDir is the directory where you have unzipped JsUnit.
<configSections> <section name="JSUnit" type="System.Configuration.NameValueSectionHandler" /></configSections><JSUnit> <add key="InstallDir" value="c:\Projects\jsunit\" /></JSUnit>
If you want more information, please ask and/or look through the unit tests used to create the JsUnitTestRunner. All comments and suggestions are welcome. All of the source code can be found in my svn repository.https://esterline.devguard.com/svn/code/WatiN.Utils/

Looks pretty nice!
Hey Adam, I really like the approach you took with integrating JsUnit using WatiN. I’m doing something very similar. I’m writing all my tests as standalone JS files which get included into a dynamic HTML page. I’m also integrating an ASHX handler to report JsUnit error descriptions in NUnit. I would like to use some of what you have done.
I guess my question is, what’s the license for your code? (https://esterline.devguard.com/svn/code/WatiN.Utils/)
It is in the public domain. You may do with it as you wish.
Cho đoạn javascript kiểm tra so sánh hai ngày :
function iesvn_CompareDate(fromDate, toDate) {
if ((fromDate == “”) || (toDate == “”)) {
return null;
}
var arrFromDate = fromDate.split(”/”);
var arrToDate = toDate.split(”/”);
if (arrFromDate.length != 3 || arrToDate.length != 3) {
return null;
}
var d1 = iesvn_GetDateFromFormat(fromDate, “d/M/yyyy”);
var d2 = iesvn_GetDateFromFormat(toDate, “d/M/yyyy”);
if (d1 == 0 || d2 == 0) {
return null;
} else {
if (d1 > d2) {
return 1;
} else {
if (d1 == d2) {
return 0;
}
}
}
return -1;
}
làm ơn chỉ cho em cách test đoạn Javascript trên. ngày hiện tiện lớn hơn ngày quá khứ; ngày hiện tại nhỏ hơn ngày o tương lai.