Our team is using Silverlight 5 for development as it has features we require going forward. I have discovered that NUnit doesn't work as standard as it isn't Silverlight and that the tools available for Silverlight testing appear to primarily be aimed at running within browsers and are a pain to automate it seems.
However a lot of the code I want to test is the View Models which aren't specifically Silverlight, so I was hoping there is a way of using NUnit or similar to just test this and integrating into a build server (which is currently being decided upon)
So, is it possible to test Silverlight in this way?
I haven't tried it but looks interesting:
http://statlight.codeplex.com/
and what about third parties (maybe Telerik offers something on their testing suite).
I know it's no ideal, but if it's just VM and non dependant on UI you can link the files to a WPF project and execute the unit tests (in our case we had to share two versions the SL and the WPF one that's why we chose to test our VM in the WPF version :-)).
The unit testing from Silverlight (toolkit) I haven't found a way to link it to an automated build process
The best solution I have found is AgUnit:
http://agunit.codeplex.com/
AgUnit is an open source plugin for ReSharper. This solution of course assumes that you're using ReSharper. AgUnit allows you to run Silverlight unit tests in the ReSharper test running. Unfortunately, I just checked the AgUnit site and it looks like they only support Silverlight 5. You may want to head over there and find out about their plans for supporting Silverlight 5 though as it is a great plugin.
Prior to using AgUnit, we were using Statlight and found it to be pretty good as well, just not quite as convenient as AgUnit.
Related
I have been using Selenium (WebDriver) for some time now, utilising Microsoft Team Foundation Server (VS2010, Microsoft Test Manager, Lab Management) to trigger my automated tests on specified builds. This has been working great and I have even written a wrapper framework to allow for a lot of re-usability and switching to WatiN should it be needed.
My issue is, now the applications I am to test are Windows Forms (with infragistics and Teecharts), not Web Applications, and I am under the impression from my research that both Selenium and WatiN will now be inappropriate. I have been reading about NUnitForms and White as they appear to be common free choices amongst SO posts asking a similar question. However, I am wondering if anyone has had experience with setting up TFS with automated UI tests for a Windows Forms Application?
Or, failing that, has anyone used Visual Studio 2010 with a free Windows Forms UI testing package and had some success? My plan is to try White/NUnitForms next week, but though I would look for some personal recounts just in case this is not worth pursuing.
After some more reading and checking around SO, I have found a few more helpful links. I am still at a loss as to a solid way to do things but am confident it can be done.
The following links I found helpful; winforms Post on SO, Continuous Integration in White Documentation (I missed this initially somehow...), and as a further look I found utilising NUnit with White TFS is fully supported for my needs. NUnit with TFS can be found here.
Hope this helps anyone in the same position, and I welcome any further answers as I still have not commenced any actual testing.
EDIT:
Have decided to use White with NUnit as NUnit has a lot of documentation with results integrated with TFS and White is somewhat of a wrapper to Visual Studio's Automation Tools.
We have a WinForms application that we're planning to port to Silverlight. Obviously the UI will need to be totally rewritten, but we have a lot of business logic that's well-tested with NUnit tests. We use ReSharper to run the tests inside the IDE, and nunit-console to run the tests on the continuous integration machines.
As we start moving our business-logic classes into Silverlight assemblies, how do we get these unit tests to run against those Silverlight assemblies? My understanding is that NUnit can't run Silverlight tests without significant tweaking, and said tweaking (in the form of a project template) appears to be VS2008- and Silverlight 3-specific (we'll most likely be using VS2010 and Silverlight 4 for our port).
We can move our tests to another testing framework if that's the best option, but there doesn't seem to be much else besides NUnit. The Silverlight Unit Test Framework looks like it runs inside the browser, which is a non-starter for continuous integration.
I'm aware that Silverlight 4.0 assemblies can be loaded into a .NET 4.0 executable, but I'm unsure of what this means for unit testing. Would it work to compile our business-logic assembly as a Silverlight 4.0 DLL, and write a full-framework .NET 4.0 NUnit test assembly that references the Silverlight DLL? It seems like this might work, but has anyone done this successfully with unit tests?
Bottom line, what should we do for our unit tests? We need a solution that
still lets us run tests in the ReSharper test runner;
can also be run from the command line;
works in VS2010.
We don't instantiate any UI objects in our tests, so those pesky DependencyObject threading issues aren't a concern. We just need to test our Silverlight business logic.
Not sure if NUnit is supported or how difficult it would be to add, but you might check out http://AGunit.codeplex.com for ReSharper Silverlight support.
I wrote a little tool to C.I. silverlight tests and attempt to help in normal dev/tdd scenarios - you can go check out http://StatLight.codeplex.com.
You should be able to find an NUnit build for silverlight out there (there's a few). Not sure of any runners that work with NUnit in the browser. However StatLight can run some basic NUnit functionality for you.
Hope this gives you a little help.
Having never written a production quality Silverlight app, I am looking to find a quality open source reference application for Silverlight 3.0 (Silverlight 4.0 is no good as I have VS2008) to help learn Silverlight.
Ideally I'd like to see:
a line of business application, in the client-server tradition.
SQL Server back end
no use of 3rd party libraries like PRISM or CSLA as I would like to see how the core Silverlight technologies work.
I realise there are plenty of open source projects on Codeplex, but struggled to find any classic line of business apps there.
This is a really good one:
http://timecard.codeplex.com/
The following does use Prism, but you can learn a lot from it. It even shows localization:
http://happynet.codeplex.com/
In all honesty, get yourself upgraded to VS 2010. If you are serious about becoming a professional in Silverlight development, version 4 has the most bang-for-your-buck.
Not all the newer technologies are supported for Silverlight 3 and all the latest cool tutorials and project examples tend to be in VS2010/SL4.
You also should not ignore patterns like MVVM and libraries like Prism & MEF as they are rapidly becoming commonplace for Silverlight projects. There is more danger of you getting into Win-forms-style bad habits if you use a Win-forms style approach to Silverlight at first.
Here is a simple explanation of MVVM for Silverlight:
http://openlightgroup.net/Blog/tabid/58/EntryId/89/Silverlight-View-Model-Style-An-Overly-Simplified-Explanation.aspx
These videos are a good introduction to creating/understanding Prism-based projects, specifically for Silverlight:
http://channel9.msdn.com/posts/mtaulty/Prism--Silverlight-Part-1-Taking-Sketched-Code-Towards-Unity/
It includes him building an Outlook-style application using prism (with full source provided).
The codeplex project, full source and documents etc, for Prism and soon MEF is here:
http://compositewpf.codeplex.com/wikipage?title=Getting%20Started&referringTitle=Home
Prism was created by Microsoft and will soon have a final release of version 4 (including MEF).
HI All
Is there a version of Reshaper that can be used to run Silverlight unit test. I am using Resharper 4.5 although it shows test icons against test methods in the class, but it does actually run the test.
Thanks
I'm the author of the AgUnit plugin.
Silverlight 3 support is currently working if you build the plugin from source, a new release is coming in the next couple of weeks.
If you want to run the tests on a build server, you should take a look at StatLight: http://statlight.codeplex.com/ You should be able to set it up easily with TeamCity.
Update: Silverlight 3 support should be working in the new 0.2 release of AgUnit.
I doubt it, although I am happy to be proven wrong. The test runner for MS Silverlight Unit Test suite is actually a Silverlight app, that runs in the browser. This is done in order to simulate the Silverlight runtime environment, which is different from desktop runtime.
Try this:
http://agunit.codeplex.com/
How to unit test Silverlight 3 Out-Of-Browser application?
Roy Osherove has created an open source framework to test silverlight controls
It called SilverUnit and it uses Typemock in order to intercept .NET calls and fake their behaviour.
SilverUnit lets you test your controls using simple unit testing framework no browser required.
Seems like a good solution for what you're looking for.
Since you are into beta stuff (Silverlight 3), are you willing to consider using VS 2010?
If so, take a look at Mathew Aniyan's blog. He has lots of information on data driven Coded UI Tests.