I am trying to write some complicated acceptance tests for my C# code. I notice that when I am writing my tests I am doing a lot of explicit casting to satisfy the C# compiler. I like the type-safety I get in my production code with a statically-typed language like C#, but for my tests I would be happy to use a dynamically-typed language (e.g. IronPython or IronRuby) to avoid all the explicit casting. If my test calls a method that doesn't exist on an object, it would be OK for the code to fail at run time (it's just a failing test). I am currently using MS Test as my unit testing framework, and it would be convenient if I could continue to use it. What dynamic (DLR-based) language can I use that will integrate with MS Test? Feel free to suggest a different testing framework, if you think that would help.
+2
A:
I prefer C# for unit testing... If you are looking for dynamic language you can try iron-python for that....
Software Enthusiastic
2009-05-04 12:08:05
+2
A:
For IronRuby and Rspec you could check out this post:
http://msdn.microsoft.com/en-us/magazine/dd453038.aspx
And http://msdn.microsoft.com/sv-se/magazine/dd434651(en-us).aspx for getting started with IronRuby .Net interop.
Then there is always fitnesse:
Fitnesse .net 1.1 and 2.0 binaries can be found here: http://fitnesse.org/FitNesse.DotNet
Presidenten
2009-05-04 12:52:09
Thanks for the links. I'm still looking for a dynamic language that I can integrate into MS Test (which means it must support .NET Attributes on types and methods), but I'll consider RSpec if I can't find anything that works.
Robert Lewis
2009-05-04 20:22:47
+1
A:
I recommend IronPython -- among its advantages is the excellent book "IronPython in Action" which will lead you through every important aspect, including testing.
Alex Martelli
2009-05-04 16:00:51
After some further investigation I see that the ScriptEngine class from the DLR can be used to call either IronRuby or IronPython scripts, and to pass objects to them. I think the best way forward in the short term is to write stub test methods (decorated with the [TestMethod] attribute) and to invoke a different dynamic script for each one. I downloaded sample code from the IronPython book which shows how to do this. When C# 4.0 comes out, I can use the 'dynamic' keyword and I won't need external scripts at all.
Robert Lewis
2009-05-05 15:10:11