Nunit. Test Driven Development with Javascript jstestdriver. Just got back from the gym and it’s time for yet another evening of experimenting with test driven development in javascript.
I’ve been hearing a lot about JsTestDriver lately, so tonight I’m going to see what all the fuss is about. I’m currently looking over the page at right now… and so far I like what I see. It seems that js-test-driver isn’t just a TDD framework, but a whole test runner that runs tests in every configured browser. Not that we haven’t seen this before, but so far I like what I see. They even include a video of it in action, which is very good. Alright, enough of that. The Dirty Details The syntax reminds me of berlios.de jsunit. which I like as it is nicely object oriented.
License js-test-driver is licensed under the Apache License 2.0, a far cry from the usual MIT license of other javascript related stuff. Last Update The latest release as of this writing is dated May 23, 2009. Support In addition to the wiki on Google Code, there is also a google group. Alright! Abbot framework for automated testing of Java GUI components and programs. Automated Web Testing with Selenium Driven by .Net - Jeremy D. Miller. The Agile development community has struggled for years with an array of solutions for automated testing solutions for web development.
NUnitASP is a good way to unit test server side ASP.Net code, especially now that it doesn’t require XHTML compliant pages, but it can’t handle client side scripting and AJAX is exploding in popularity. Several tools have used COM (must die) to drive Internet Explorer (IE) with varying degrees of success. My personal experience is that the IE COM API is too byzantine and flat out flaky. Besides the flakiness, Firefox and other browsers are gaining in popularity so the IE only testing might not cut it anymore. Enter the Selenium project. Sample Test The API libraries communicate with the Selenium Server, a Java executable that can start and stop any supported browser and send testing commands to the browser. Java -jar server\selenium-server.jar -interactive <title>Selenium Target Page</title> function button1_onclick() { <option value="1">North</option>
Using Rhino Mocks To Unit Test Events on Interfaces. Rhino I am working on some code using the Model View Presenter pattern for an article I am writing.
I am using an event based approach based on the work that Fowler did. For the sake of this discussion, here is an example of a simplified view interface. public interface IView{ event EventHandler Load;} In the spirit of TDD I follow this up with the shell of my Presenter class public class Presenter{ public Presenter(IView view) { throw new NotImplementedException("Not implemented. "); }} And this is where I reached my first dilemma. [Test]public void VerifyAttachesToViewEvents(){ MockRepository mocks = new MockRepository(); IView viewMock = (IView)mocks.CreateMock(typeof(IView)); viewMock.Load += null; LastCall.IgnoreArguments(); mocks.ReplayAll(); new Presenter(viewMock); mocks.VerifyAll(); } The second line of code creates a dynamic proxy that implements the IView interface. Finally we call ReplayAll(). Now my test passes. I then write my test. Now when I run the test, it succeeds.