CodeSOD: Excellent Test
by Remy Porter from The Daily WTF on (#1YBJM)
These days, you aren't just doing development. Your development has to be driven. Business driven. Domain driven. Test driven.
TDD is generally held up as a tool for improving developer efficiency and code quality. As it turns out, scholarly research doesn't support that: there's no indication that TDD has any impact at all.
I have to wonder, though, if maybe that's because people are still writing tests like this one, which Tomas received from an offshore contractor.
public void CompareValues(string con, int pf, int pt, string tableVal, int len, string Ledpos1) { string databasevalue1 = (con.Substring(pf-1,len)).Trim(); string tableval = tableVal.Trim(); switch (pf) { case 61: Assert.AreEqual(databasevalue1, "00000" + Ledpos1, " Values are not equal "); Console.WriteLine("Excellent!"); break; case 76: Console.WriteLine("Not check as it is random values"); break; case 164: Console.WriteLine("TIME!"); break; case 160: string todayDate = DateTime.Now.ToString("yyyyMMdd"); Assert.AreEqual(todayDate, databasevalue1, "Both dates are not equal"); break; case 270: string tOnedate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"); Assert.AreEqual(tOnedate, databasevalue1, "Both dates are not equal"); break; default: Console.WriteLine(pf + pt + len + tableval + databasevalue1); Assert.AreEqual(tableval, databasevalue1, "Both values are not equal"); break; } Console.WriteLine(pf + pt + len + tableval + databasevalue1); }
"Excellent", indeed.
[Advertisement] Application Release Automation for DevOps - integrating with best of breed development tools. Free for teams with up to 5 users. Download and learn more today!