|
|
Jul
15
Posted by:
Philip Beadle
Tuesday, July 15, 2008 12:00 AM
I have completed the template for VS2008 that I was building so I could build TDD DNN Modules easily. Download it from Code Plex. Here's how to use it.
The vbproj for the module has some modifications to allow you to develop outside the DesktopModules folder, see this post for details http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1873/Default.aspx. The following steps require you to follow this development practice.
Also you will need to use an object qulifier on your db, which of course you do anyway right , and the Unit Tests use TransactionScope so you will need to start the MS DTC Service.
- Create a New Project and select the C# Web Folder and select the TestDrivenDNNModule.Tests template. Make sure you put the tests into a subfolder of your module usually called Tests. Name the tests project the same name as the Module project you will add soon. Youu need to do this so the namespaces and object names in both projects are aligned.

- You will now see the Documentation.htm file opened with the rest of the instructions.

- Rename this test project to TestDrivenDNNModule4.Tests

- Select Add New Reference and find the DotNetNuke.dll assembly in the File Dialog.

- This test project also needs to access the database so you will need to set up the connection string in the SqlDataProviderFixture.cs file.

- Add a New project and select the TestDrivenDNNModule template and name the project TestDrivenDNNModule4 and put it in the parent folder of the tests project you added first..

- Edit the Project properties by double-cliking on the My Project folder in Solution Explorer.
- Make sure that the Application Tab is selected
- Make sure the Root Namespace text-box is empty, and save the Project.

- Select Add New Reference and find the DotNetNuke.dll and Microsoft.ApplicationBlocks.Data assemblies in the File Dialog.
- Build the Module project and then add a project reference to the TestDrivenDNNModule4 Module from the tests project.

- Install your new module as per normal and you will be able to run the Unit Tests.

Tags:
19 comment(s) so far...
Re: Test Driven Development for DNN Modules Template - How to use it
Looking forward to testing this template out Phil.
By cnurse on
Wednesday, July 16, 2008 9:43 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Thanx Charles, Im using it for the Help module and its going really well.
By philip.beadle on
Wednesday, July 16, 2008 9:43 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Looks pretty interesting. Do you have instructions for how to implement using this for existing modules? I'd like to write some unit test for the existing functionality for the Test Cass module and then use it for the next release. When will you post an the first official release on CodePlex for this project?
By smehaffie on
Thursday, July 17, 2008 9:34 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Hi Shawn, you have to use DNN 5 for this. As for retro fitting its a bit of work as you have to completely change the pattern of the existing module to use the MVP pattern, can be done. What you need to do is create the Interfaces, change the ascx.vb files to Implement the interfaces, then move all the code behind into the Presenter classes. Once you have done that you can then write your Mocks. I can help you out if you like. Buzz me on IM. Official relase is already on CodePlex.
By philip.beadle on
Thursday, July 17, 2008 9:38 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Thanks Phil, when I get to working on the next version of TestCases I will probably be contacting you. Of course, I will try to do it on my own and screw it up several time, but that is what source control and backups are for right? I see the official release now on codeplex now, when I made my post when you click on releases it stated that there were not official releases for the project yet. I now the files were in the download area, just being a pain in the ass.....about it there being an official release. :-)
By smehaffie on
Sunday, July 20, 2008 4:52 PM
|
Re: Test Driven Development for DNN Modules Template - How to use it
In you post you say:
"The vbproj for the module has some modifications to allow you to develop outside the DesktopModules folder, see this post for details http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1873/Default.aspx. The following steps require you to follow this development practice. Does this mean to create TDD DNN Module Templates you have to develop outside the DesktopModule Folder?
By smehaffie on
Sunday, July 20, 2008 4:52 PM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Hi Shawn, you can develop as per normal just mod the vbproj file back to normal. I prefer doing it outside the desktop folder as you dont then rely on a particular DNN isntall.
By philip.beadle on
Sunday, July 20, 2008 4:53 PM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Just got word the Blog Team is going to rewrite the Blog module and do it TDD :) :) happy days. Now to work on the Core.
By philip.beadle on
Thursday, July 24, 2008 3:39 PM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Hi, I'm running version 4.8.4 I follow step until 11 and stop cause cant build the project. Got 33 error. Is it you missing something? Please Advice.
By caesartan on
Wednesday, August 13, 2008 9:02 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
I thought the point of TDD was to avoid using costly resources such as the database?
By neilx on
Wednesday, August 13, 2008 9:03 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
This is for DNN 5 only. Does not work on earlier versions.
By philip.beadle on
Wednesday, August 13, 2008 9:02 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
The point of TDD is to test your code. Unit tests will test a Unit of code as such you test each layer, if one of those layers is the db then you still need to test it.
By philip.beadle on
Wednesday, August 13, 2008 9:04 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
nelix the point of TDD is to prove that your code works as expected, hitting the database in the sqldataprovider is not a true unit test because it uses resources but it does provide valuable insight.
By Philip Beadle on
Tuesday, January 13, 2009 7:03 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
caesartan you must be using DNN 5
By Philip Beadle on
Tuesday, January 13, 2009 7:03 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Philip - Thanks for your response. I guess I shouldn't be too religious about TDD:-) We - our team of 4 developers - are starting TDD on a bunch of planned dnn custom modules in earnest this week, so I am looking forward to seeing how this works out. Is there a place to discuss TDD experiences with this DNN approach? - Neil
By Neil Burnett on
Tuesday, July 21, 2009 3:40 PM
|
Re: Test Driven Development for DNN Modules Template - How to use it
I've followed your instructions but once I get to the point where I run the tests, I get this error:
Warning: conflict during test run deployment: deployment item 'C:\DotNetNuke\Template tests\TestDrivenDNNModule\Bin\TestDrivenDNNModule.dll' directly or indirectly referenced by C:\DotNetNuke\Template tests\tests\TestDrivenDNNModule\bin\Debug\TestDrivenDNNModule.dll cannot be deployed to 'TestDrivenDNNModule.dll' because otherwise the file 'C:\DotNetNuke\Template tests\TestDrivenDNNModule\Bin\TestDrivenDNNModule.dll' would overwrite deployment item 'c:\dotnetnuke\template tests\tests\testdrivendnnmodule\bin\debug\testdrivendnnmodule.dll' specified by the test assembly 'c:\dotnetnuke\template tests\tests\testdrivendnnmodule\bin\debug\testdrivendnnmodule.dll'.
Any thoughts?
By Nathan Rover on
Tuesday, July 21, 2009 3:40 PM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Philip,
Great job, exactly what we all need to embrace Module Development in TDD. Did you ever try to make it run in nUnit or other unit test tool? I was wondering on how you bypassed around HTTPContext and caching DNN uses? I have read the article by Phill Haack on how to unittest web projects but it seems to have another level of complexity added by DNN.
Also, I was wondering if you ever had any intentions to make your testable module template project in C#. For some reasons I thought it was in C# since you have your example shown in C# but downloaded project was in VB, am I missing something?
Great job again in setting right trend
Thanks
By Dmitry Starchuk on
Friday, November 13, 2009 7:58 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Hi Dmitry, The way I do the testing you dont need the context as Im only testing classes and not the page. In another project Im doing automationtesting which tests the page. The module is in VB.Net and tests are in C# because I likie C# better the way it handles interfaces. You'll see a LOT more work going in this area now that Im on the Corp Engineering team.
By Philip Beadle on
Friday, November 13, 2009 8:01 AM
|
Re: Test Driven Development for DNN Modules Template - How to use it
Hi Nathan, I haven't come across that issue before. I'll have a look into it as Im about to update the project.
By Philip Beadle on
Friday, November 13, 2009 8:03 AM
|
|


Follow us on Twitter @DNNCorp or join the DotNetNuke Community on LinkedIn
|