Darrell Hawley: Home Page

Tuesday, June 10, 2008

NUnit and IronPython

A while back, I came across this post from the Bitter Coder telling you how to use IronPython with NUnit. It's an interesting approach in that you actually put your *.py files inside of a C# project. Though you won't be able to easily test external IronPython code without using the Hosting APIs, it actually is a great way to introduce Python (and unit testing) into your environment. Of course you'll need to be willing to rip your tests apart as our method of communicating with the DLR languages evolves.

When you download the source code from the Bitter Coder, you'll need to make a couple of tweaks.

  • Rename IronPythonTest.Framework.PythonSuiteAttribute to PythonFixtureAttribute. Make sure you use a refactoring tool (either the one that comes with Visual Studio or a third party tool) so that you can be certain that all instances of PythonSuiteAttribute are changed.
  • I needed to update my nunit.framework reference in the IronPythonTest.Addin project. It may behoove you to update all of your NUnit references to the version you are using.
  • The nunit.framework reference I just mentioned was also set to copy local. This doesn't really hurt, but none of the NUnit libraries are set to do this. It's just aesthetics.
  • There are a couple of references throughout the solution - nunit.addin for one - that can't be found. They seem to be artifacts from an earlier iteration and can be removed.

That should do it. Tip o' the hat to the Bitter Coder.

0 Comments:

Post a Comment

<< Home