Steve Hebert's Development Blog

.Steve's .Blog

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Blogs I Follow

Favorite Tools

Development Articles

Subscriptions

Post Categories

Article Categories



.Math and TDD

I'm working backward (from a TDD perspective) on completing tests for the .Math library and finished off a series of these tests last night. I previously blogged the decision to add a testing set along with the reasoning and arguments for it.  Here are a couple of thoughts on the process so far.

  1. Improved confidence in the code.  I have no way to qualify or quantify this “feeling“, however the confidence around modifying core components is significantly improved.
  2. Range Testing across functions.  I'm looking to do range testing across tests by pushing this up into the scaffolding.   The primary reason is to allow for similar tests to be run while minimizing duplication of code.

I think (2) steps outside the range of TDD methodology because the individual tests lose their atomic nature.  However the value in performing these is significant. My next step is to look into this process, but here is a simplified version of the code driving the push.

private EqCompiler GetCompilerSetup( string sFunction )
{
   EqCompiler oComp = new EqCompiler( sFunction, true );
   oComp.SetVariable(“a“, m_a);

   return oComp;
}

[Test] public void Sqrt()
{
   EqCompiler oComp = GetCompilerSetup("sqrt(a)");
   AssertEquals( oComp.Calculate(), Math.Sqrt(m_a));
}

[Test] public void Tan()
{
   EqCompiler oComp = GetCompilerSetup("tan(a)");
   AssertEquals( oComp.Calculate(), Math.Tan(m_a));
}


I am looking to alternate the values of 'a' over the course of the test - something in psuedo-code that looks like:

for( a= -100; a < 101; a++)
{
   SetValueOfA(a);
   Sqrt();
   Tan();
}

This psuedo-code is a bit misleading, because I want to maintain visibility of each test in NUnit.  I know a quick way to perform this task, but I want to check out all my options first and make certain I'm making the best use of the NUnit framework.

My gut feeling tells me this violates some of the ideas of TDD because now I'm allowing the scaffolding to change the runtime values. However, I should be able to do this under my own design and it allows for building out the test capabilities.

 

posted on Tuesday, June 08, 2004 10:44 AM by sdhebert





Powered by Dot Net Junkies, by Telligent Systems