Bad, very bad, test unit test....
-
We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes..... ...when testing a change one of the developers made I noticed that the expected change didn't happen. He said to me it should work, and he's created a unit test to test the change works... ...I then looked at his unit test: if (order.Allocations[0].TriPartyEligibilityCriteria != null) { Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); } I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead! The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke
-
We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes..... ...when testing a change one of the developers made I noticed that the expected change didn't happen. He said to me it should work, and he's created a unit test to test the change works... ...I then looked at his unit test: if (order.Allocations[0].TriPartyEligibilityCriteria != null) { Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); } I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead! The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke
Suffering in a similar fashion though the code, itself, works most of the time. They are just so untidy.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes..... ...when testing a change one of the developers made I noticed that the expected change didn't happen. He said to me it should work, and he's created a unit test to test the change works... ...I then looked at his unit test: if (order.Allocations[0].TriPartyEligibilityCriteria != null) { Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); } I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead! The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke
-
You could certainly assert the length as part of the test, but the check for null is wrong - you should know if the value will be null or not and do an assertion on that (it may be valid for it to be null, for example if some other property is invalid, but this should be part of the spec).
-
You could certainly assert the length as part of the test, but the check for null is wrong - you should know if the value will be null or not and do an assertion on that (it may be valid for it to be null, for example if some other property is invalid, but this should be part of the spec).