I tried to reply to this post, but the comment form never posted. What I see is a common question that I have regarding TDD and unit testing in general: what makes a good unit test?
In the code challenge graciously put on by Thycotic, we are asked to implement a conversion function between their Base13 number system and common Base10 number system.
The instructions state that our “task is to implement the Converter.Convert method for this new number system to get all the unit tests passing.”
However, making all of the unit tests pass in this case is not the same as having a correct solution. The following code would successfully pass all unit tests, but not be correct.
public class Converter
{
public string Convert(int number)
{
switch (number)
{
case 5:
return "5";
case 10:
return "x";
case 13:
return "10";
case 20:
return "17";
case 5006:
return "2381";
case 9999999:
return "20z1879";
default:
return "";
}
}
}
I wonder what the best approach for unit testing functionality like this is?
Elementary School Jake Gyllenhaal Picture
(via jacktwistbbm)