Tuesday, March 15, 2011

Unit testing another attempt

After attempting to give unit testing another go and possibly even take parts of the code we already have and just testing those parts I am still unsuccessful. The other had told me that you couldn't unit test and I was trying to prove them wrong but in the end they were right. There are ways to Unit test C# code but once XNA is involved you simply can't do it.

A lot of books and websites all reference a program called NUnit which is a graphical or command line way to run the tests you create through the code within your class library. After trying and succeeding on the simple examples. I thought I could be able to manipulate this to work it with the code we have but it just isn't possible.

Here are some examples of the what I tried to achieve:

Here is a function within the CubicSpline class. I add this to a file then tried to do an assertion on it.
This all compiled and built successfully however when I tried to test it through the use of NUnit which uses test runners in the code to find which parts of the code are the tests

Above is the result I got from trying to run a simple assertion of the code above. I dont know if that error is readable but it says:


ClassLibrary1.TestLargest.TestGetCubicSpline:
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.Xna.Framework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d' or one of its dependencies. The system cannot find the file specified.

Which simply means that this Unit testing will not work for XNA framework which is difficult when the our whole project is built using XNA framework

No comments:

Post a Comment