Testing Silverlight Modules

I looked for this information and saw similar questions, but not one that is very close to this. If I missed one, I apologize. I was hoping you could point me in the direction. I am working on a Silverlight-based project, and my team is finally moving towards implementing unit testing. I and another member of my team are responsible for recommending a unit testing system for the project. Our main criteria:

  • The project contains the standard ASMX.NET web services and the Silverlight interface. We would prefer, if at all possible, to maintain the same test attributes everywhere, rather than using one set for Silverlight tests, and another for different code.

  • Integration with VS 2008 is pretty important. We would like all this to be under one roof, if possible. We would be happy if we simply removed the unit test from VS.

  • Automated assembly / validation testing. We are currently working in a fully non-automated environment, VS 2008 / VSS 2005. We are in the process of switching to SVN for version control, and our corporate office will help us use MSBuild to automate the build process. Of course, we would prefer to integrate as much as possible into this environment. I am not sure of the details of this process, as I am not directly involved. If you need more details, please let me know and I will see what I can find out.

At this point, my college and I are looking at NUnit (along with Silverlight Silverlight features) and MSTest in conjunction with the Silverlight testing platform, written by Jeff Wilcox. While NUnit is the standard standard, they are open to other options, as there are no other commands that do the work of Silverlight.

I am halfway through the Roy Osherove Unit Testing Book , so I feel ready to write tests in general. I am not married to a specific structure, but the corporation seems to be most open to NUnit or MSTest. I would also like, if possible, to get a good MSTest tutorial.

Thanks for taking the time. If you need any other information from me, feel free to ask.

Greetings

Steve

+4
source share
2 answers

Test carefully and be sure to try these features. The easiest way to find out what you are looking for is by writing a few tests in each and finding out what your workflow will be like.

Silverlight unit test systems are less mature there than officially shipped, full-fledged test environments for the .NET environment on the desktop, so your experience may vary. Understand that today's Silverlight test solutions (which actually run inside a web browser) specifically help people to get information about their code and components in the context of the Silverlight platform, and not necessarily for quick or easy testing, which you can get through the integrated Visual Studio tools .

The isolated security model for Silverlight makes many standard testing tools that you can expect much more difficult.

In fact, this is another platform, so it may not make sense to run each test (for example: a "load test" for a web application ... you can "emphasize" a Silverlight application or look at its "performance" but a "load test" it refers to underlining your machine hosting the .XAP file, and is not very interesting for Silverlight applications).

If you are more worried about testing your business logic and good integration, we strongly recommend writing enough layout / IoC code so that you can develop most of your application and test the version created as a regular .NET desktop library ~ you could have a subset of the tests that are only Silverlight in the browser.

To your notes:

  • Are you really going to test web service calls with your tests? Such integration / client + server testing can be very, very difficult for Silverlight client code and web service to execute correctly.

  • Integration with the Visual Studio 2008 IDE for the Silverlight unit test environment will not be great. You may have a Silverlight test project / application that you can press F5 to open and debug in Visual Studio and run the tests. However, you will not be able to right-click Run All Tests or process case management tools.

  • Automated test verification for the Silverlight module testing platform is something that is slowly evolving; some people have written the Silverlight test suite on CodePlex. You may not get this easily, and your builder / test computer will need to be configured so that the build service runs instead as the actual user process so that it can open and control the web browser.

In the future, in the Silverlight Toolkit team, in the future we will release some level of automated testing support, as well as simple code coverage support, but these tools are currently unavailable (October '09)

+2
source

I will not recommend a unit testing system, but I can warn that the Test attributes in MSTest are sealed (cannot be inherited in the new custom attribute that you create), unlike NUnit. In my opinion, this fact should not matter much, because I also suggest that, depending on which testing environment you are in, stick to your only Test attribute, and not create your own inherited one. To denote special tests (e.g. Silverlight, as you mentioned), you must add an additional attribute. A difficult bit comes when you want to run only those tests that use your custom attribute (unlike all unit tests), and for this you need a special driver for the tests.

Hope this helps.

0
source

All Articles