Continued from Part 1 where I was trying to structure up the solution.
After reading “ASP.NET MVC in Action” I’m really keen to try Gallio with MbUnit. As for a mocking framework i decided to ditch Rhino.Mocks this time and go with Moq. I’ve heard so many praises from my fellas on it, so it can time to learn new tricks. I gave a last chance to Rhino.Mocks by going to the download page to see the latest changes and found a last release being 4 months old there. Good-bye Rhino.Mocks!
Gallio and MbUnit come in a bundle. You can get it here http://code.google.com/p/mb-unit/downloads/list.
|When picking a download on Moq project I started to feel a bit of anxiety when seeing Moq.Silverlight binaries to download. Will those be some manual mocks for Silverlight? Can’t wait to explore in the next installment. You can get your copy here http://code.google.com/p/moq/.|
A look at the default test generated by VS.
When executing the test, I first thought VS is frozen, but then I understood that actually VS was starting a browser, first test took around 10s and probably it will be faster then. But wait, is this a unit test then?!
///A test for Index
// TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
// http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
// whether you are testing a page, web service, or a WCF service.
public void IndexTest()
HomeController target = new HomeController(); // TODO: Initialize to an appropriate value
actual = target.Index();
Assert.Inconclusive("Verify the correctness of this test method.");
My intent would be to have real unit tests and only after that creating integration/ui tests with Gallio/MbUnit and WatiN.
Employing Gallio/MbUNit for MVC unit tests.
Creating own unit testing project template.
VS is nicely offering the option to import the template after the export.
Getting some lame UI test in place.
This time going to use guidance from the “ASP.NET MVC in Action”. You can get WatiN from http://watin.sourceforge.net/.
|Right at the start, issue with shdocvw.dll. Here is the link to the solution http://geekswithblogs.net/coredump/archive/2007/09/06/115181.aspx – reference ShDocVw.dll from the System32 directory.|
ShDocVw fixed now running into:
System.Runtime.InteropServices.COMException: The interface is unknown. (Exception from HRESULT: 0x800706B5)
at SHDocVw.InternetExplorerClass.set_Visible(Boolean pBool)
I worked around this one by running VS as an administrator (SHAME!) http://codeblog.theg2.net/2009/12/watin-20-and-gallio-31-in-x64.html with additional info on stackoverflow http://stackoverflow.com/questions/1014815/how-do-you-get-watin-to-work-on-windows-server-2008-with-ie8
|Anyway, got it working! One more thing was to set it up on IIS on my Windows 7 so it had more taste of an “integration” testing.|
This is it for the sprint planned.
Integrating Silverlight into the solution and seeing what are options for its testing.
Platform and tools: Windows 7, VS2010RC, ASP.NET MVC2 RC, Gallio, MbUnit, NUnit, Moq, Silverlight 3.0