Refactoring within TestFixtures, Anyone? NUnit and NUnitAddin
I recently just started fooling around with the NUnit and NUnitAddin framework for my current project. See NUnitAddIn . I was doing the test-driven coding part when I realized that in this case, the framework always returns an incomplete test (a yellow mark when testing doCommon) when I try to refactor within this particular TestFixture:
[TestFixture]
public class MyObjectTest {
MyObject myObject;
[SetUp]
public void SetUp()
{
myObject = new MyObject();
//...
}
[TearDown]
public void TearDown()
{
// ...
}
[Test]
public void TestDoProcess()
{
Assertion.AssertEquals("GetRange",myObject.i,2);
doCommon(myObject);
myObject.DoProcess();
Assertion.AssertEquals("GetRange",myObject.i,1);
}
[Test]
public void TestDoReset()
{
Assertion.AssertEquals("GetRange",myObject.i,2) ;
doCommon(myObject);
myObject.DoReset();
Assertion.AssertEquals("GetRange",myObject.i,0);
}
//this will not be ignored!
//[Ignore("This is not a test!")]
public void doCommon(MyObject anObject)
{
//do common processing on anObject
anObject.DoCommonProcess1();
anObject.DoCommonProcess2();
//...
}
}
I get the following:
Running doCommon TestCase
'HotBlue.Utility.MyObjectTest.doCommon' not executed: Method doCommon's signature is not correct: it must not have parameters.
Since the doCommon( ) member function was originally an ignored test case, adding the [Ignore("This is not a test!")] attribute will still result to the logging of a non-tested attribute, therefore I'd still get a yellow light.
My question is, what's the [Test] attribute for if it doesn't differentiate a normal member from a testable member? What am I doing wrong, methinks?
It's a funky tool all in all, but can I refactor?


0 Comments:
Post a Comment
<< Home