mardi 28 avril 2015

Why do we write test cases?

So I know you might say, this is not a good question and a simple search can give me my answer, but it is not true. I have read a lot about testing and its importance. I know writing test cases helps to find the potential errors while programming. Also when you read the books they all are just repeating the same abstract definition. But after writing a lot of test cases, I came to this conclusion that it is not that much helpful neither preventing the potential errors nor increasing the product quality.

So just imagine we have a test case as below over a bunch of our functions:

Assert.IsTrue(divideNumbers(4,3) == 1);
Assert.IsTrue(divideNumbers(4,2) == 2);
Assert.AreEqual(divideNumbers(8, 4), 2);
Assert.That(divide(10,2), Eq(5))

So, while writing a test case, normally we are trying to assert the truthfulness of a bunch of very basic issues like Are two equations true? Is the result of this function equal to a desired result? Are they equal? Does it fail? Is an object an instance of a specified class?,.......

I have worked in a lot of software development teams. Almost in all the times and in all the teams, after writing some test cases we encounter a situation where we see the functions of Assert Class can't help us since they are very basic while the errors normally raises in a specific situations that are not a matter of being true, being equal, not being null,....

So, why do really write test cases? Why we really need them and how they can help us increasing the product quality and decreasing the potential errors?

Aucun commentaire:

Enregistrer un commentaire