What is the standard, best practice way to perform unit testing in a dotnetnuke app? I have searched SO as well as the dnn website, and wasn't able to find much info about this. I assume dnn has something baked in for doing unit tests, or at the very least a library that can be plugged in. Where can I find more info? A tutorial on the subject would be ideal, but any resource at all would be appreciated.
Thanks!
xUnit.net is a free, open source, community-focused unit testing tool for the . NET Framework. Written by the original inventor of NUnit v2, xUnit.net is the latest technology for unit testing C#, F#, VB.NET and other . NET languages. xUnit.net works with ReSharper, CodeRush, TestDriven.NET and Xamarin.
Facts and theories While facts are used to test invariant conditions, theories are tests that are true for a particular set of data passed as argument to the method. You would typically use the [Fact] attribute to write unit tests that have no method arguments.
There isn't much information on testing within DotNetNuke. Being a WebForms based project, it hasn't been a strong concern of many of the developers in the community.
For examples, you can look at the unit testing projects within DNN's source, which have a number of different approaches used. They use MbUnit and Moq for unit testing, as well as Watin for testing the web frontent.
The main technique for making testable modules is to use the WebForms MVP integration, so that you have testable, loosely-coupled presenters that you can inject dependencies into easily. There's the start of a sample module on codeplex, but it's never been fully fleshed out. However, it does has some good background on its project page.
For a data-driven unit testing approach, be aware of following:
Create app.config file for unit test project and copy sections related to "data", "caching" from web.config of DNN web app
Install caching provider before running any tests:
ComponentFactory.InstallComponents(New ProviderInstaller("caching", GetType(CachingProvider)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With