I’ve been working on some tests today, nothing super fancy, just some basic null tests. I originally had the following code:
if(actualEmployeeSize != null) l.EmployeeSize = actualEmployeeSize.Parse(default(int));
All I wanted to do was write 3 tests:
- Test if actualEmployeeSize is null, then l.EmployeeSize should be 0
- If actualEmployeeSize can’t parse, then l.EmployeeSize should be 0
- If actualEmployeeSize can be parsed, then l.EmployeeSize will be the parse value.
The problem is, test #1 fails for the above code. So I changed to the following.
l.EmployeeSize = actualEmployeeSize == null ? 0 : actualEmployeeSize.Parse(default(int));
I ran my each of my 3 tests individually and they all passed. I then ran all the tests in my suite using the “Run All” option in Visual Studio. Test #1 starts failing. After some digging around, and stumbling on to a similar issue over at MSDN, I realized that I had not rebuilt the release version of my assembly. I did a release build, and ran my tests, they all passed with flying colors. Apparently, the Run tests was not building my release DLL, and so it had an old version that would actually cause the test to fail.