Automating QUnit and JSTestDriver within VS2010

I briefly touched based on this during my presentation at Code Camp. There were number of developers who were interested in browser based Unit Testing. This blog post is to provide you with some information on how you would automate browser based Unit Testing with VS2010.

QUnit is a great JavaScript Unit Testing tool which allows you write powerful browser based Unit Tests. You can find more information on QUnit here.

As described in the JSTestDriver Getting Started, you can use the below command to run both Java server and the client using a single command.

java jar <path>/JsTestDriver.jar port 9876browser firefoxpath,chromepath –tests all

Next step is to automate the above command within VS2010. You can easily achieve this by using VS External Tools.

·         VS -> Tools -> External Tools ‘Add new’

·         Specify the Title E.g “Js Unit Tests Run”

·         Specify the Command – C:\Program Files\Java\jre6\bin\java.exe

(This is the path where your java runtime is located)

·         Specify the Arguments

-jar <path>/JsTestDriver.jar –port 9876 –browser  “C:\Program Files\Internet Explorer\iexplore.exe, C:\Program Files\Mozilla Firefox\firefox.exe” –tests all

·         Initial Directory is the path to the directory where the JSTestDriver is located.

·         Ensure you select the “Use Output Window” check box, so you can see the Unit Tests result in the output windows.

Once you run the VS external command, you should be able to see your output similar to below.

image

You can further automate this by running a VS macro, so every time when you save a JS file the above command will run all browser Unit Tests.

 

ASP.NET MVC 3 Preview 1 Source code

Microsoft has uploaded the source code for MVC 3 Preview 1. You can download the source code from below
http://www.microsoft.com/downloads/details.aspx?FamilyID=cb42f741-8fb1-4f43-a5fa-812096f8d1e8&displaylang=en

You can download the preview 1 from below link
http://www.microsoft.com/downloads/details.aspx?FamilyID=cb42f741-8fb1-4f43-a5fa-812096f8d1e8&displaylang=en

There are some useful features (considered to be included in MVC 3) is now available in MVC Preview 1.
Some of the features in preview 3 features are below

  • New ActionResults
  • New Razor View Engine
  • HttpNotFoundResult, HttpRedirectResult with support for Permanent Redirects, and HttpStatusCodeResult.
  • Global Filters
  • Model Binding to JSON
  • Validation – .NET 4 introduced IValidatableObject and improvements on ValidationAttribute to provide even better validation and ASP.NET MVC 3 will offer better support for them.
  • Dependency Injection and Common Service Locator Enhancements

You can find more information
http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx

http://haacked.com/archive/2010/07/27/aspnetmvc3-preview1-released.aspx
It is very early stage so there are no guarantees that all these features will be included in the final release.