flow.
"Flow is a condition of deep, nearly meditative involvement." - Tom DeMarco

Free MbUnit and NUnit Test Templates for ReSharper

Tuesday, November 06, 2007 10:18 PM
Update - 11/9/07:  Casey over at Insane World has also created and posted a set of templates for the MSTest framework.  Awesome work!  Thanks Casey!

One of the very cool features of ReSharper is the ability to design custom file templates according to your needs.  I know, I know, Visual Studio let's you do this as well but it's much simpler in ReSharper. 

And ReSharper's "New Item" list doesn't take 5 minutes to open either...like some other IDEs who shall not be named.

Anyway, I have an empty MbUnit test class template that I use on a daily basis and an NUnit test class template that I designed tonight for an upcoming talk on test driven development.  In the spirit of community, I thought that other #Heads out there may be able to benefit from these as well.  They're not much, but that extra 60 seconds they can save you every time you start a new test fixture can do wonders for your train of thought when you're deep in the code.

Here's what the NUnit template looks like...
using NUnit.Framework;
 
namespace MyMoneyDotNet.Tests
{
    [TestFixture]
    public class HappyPandaTest
    {
        [Test]
        public void First_test()
        {
        }
    }
}

And the MbUnit template...
using MbUnit.Framework;
 
namespace MyMoneyDotNet.Tests
{
    [TestFixture]
    public class HappyPandaTest
    {
        [Test]
        public void First_test()
        {
        }
    }
}

Feel free to use these templates for yourself, for your team, or to give them as gifts.  I'm granting full license amnesty to these files.  You can download them here.

kick it on DotNetKicks.com

Feedback

# re: Free MbUnit and NUnit Test Templates for ReSharper

I just posted a version for the MS unit test framework at http://blog.goinsane.co.uk/2007/11/09/ReSharper+Unit+Test+Templates.aspx


11/9/2007 7:05 AM | Casey

# re: Free MbUnit and NUnit Test Templates for ReSharper

Thanks Casey! I'm actually using MSTest now as well (yay :( ) so these will come in handy.

Thanks!
Jeremy 11/9/2007 7:57 AM | Jeremy

 re: Free MbUnit and NUnit Test Templates for ReSharper

How do you import them? 11/9/2007 10:59 AM | Joe

# re: Free MbUnit and NUnit Test Templates for ReSharper

Hey Joe,

1) Inside of Visual Studio, go to the "ReSharper" menu.
2) Open the "Options..." page
3) In the left hand tree view, go down to the "Templates" section and select "File Templates"
4) In the tree view on the top right side, select the "User Templates" node.
5) In the row of buttons over the tree view, select the "Import Templates from File" button. This is the third button from the left in my version.
6) Browse to the XML file and click OK. They should be added under the "User Templates" node
7) Click OK to close the Options page
8) Now go to the "New from Template..." menu which is available both from under the main "ReSharper" menu and by right clicking a project in the solution explorer and clicking add.
8) Select the "More..." option which will let you see all of the templates in the tree view from the options screen. Highlight your new test fixture templates and click the "Add to Quicklist" checkbox in the lower right corner.
9) Now they'll be available whenever you click "New from template..."

Hope this helps!
Jeremy 11/9/2007 12:37 PM | Jeremy

# re: Free MbUnit and NUnit Test Templates for ReSharper

Sorry .. I went and broke my permalink to the post! Switching from SubText to dasBlog is a royal PITA!

http://blog.goinsane.co.uk/2007/11/09/ReSharperUnitTestTemplates.aspx is the new and working one! 11/11/2007 11:16 AM | Casey

# re: Free MbUnit and NUnit Test Templates for ReSharper

Would be nice if Resharper had a feature to generate the test stub automatically, I really like the test session views and running tests, but test generation would ROCK! Anyone implemented a plugin for this? 8/27/2008 3:26 AM | jason

# re: Free MbUnit and NUnit Test Templates for ReSharper

Hi Jason,

I don't know of any such plug-in off hand, but you may want to check out Jetbrain's plugin page for a sample you could easily canibalize to do such a thing.
http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+Plugin+Development

good luck!
jeremy 8/27/2008 7:09 AM | Jeremy Jarrell

Post a comment





 

Please add 6 and 7 and type the answer here: