Junit test and stack overflow exception
Hallo,
I have found a strench behaviour during my unit testing. My test:
public void CreateInstance1()
{
ClassWithError instance;
instance = new ClassWithError(1);
Assert.AreEqual(1, instance.SerialNumber, "Box address created with wrong serial number.");
}
run for a while and then it was like the test never run. The whole batch of tests stopped with no message or exception. The Nunit Gui reported stack overflow exception.
There was a bug in my code for a property:
publi class ClassWithError
{
private int mySerialNumber;
public int SerialNumber
{
get { return SerialNumber; }
}
}
which caused the infinite loop of invoking it self.
The unit test shoud throw an exception, right?
Honza Muller
Please sign in to leave a comment.