Generalised Testcases: A Nightmare In A Testers' Life
Recently, one of my colleague was writing cucumber testcases for automating in a generalized manner. I feel it can be better, if it can be concrete instead of generalized one. Why?? Generalized testcase have a lot of disadvantage in long term, top most is generalized testcase’s meaning changed every time a tester read the testcase. So I introduced with a rule named concrete principle. »»
What is Concrete Principle??
Never start automating a testcase until you can have a concrete input and a concrete output beforehand.
The top advantage is whoever read it anytime, every one will have always one and only one understanding for the testcase.
My colleague was creating a testcase for wikipedia like the below one:
Given I want to search on wikipedia
When I Search for a word
Then I should be able to see the word in the heading of the search result page
It seems to be correct functionality, correct? But, will it really work in the real life??
What is the word you want to search for? What is the word you want to verify in the heading on result page?
It seems to have ambiguity in the testcase, if anytime testcase failed in the future. It would be nightmare to refactor the same. Trust me!!!
And after-refactoring not sure if it will have the same intention as same as, when it was created initially because ambiguity is present from the starting point.
The same can be updated to follow concrete principle, like below one:
When I search for word “Neema” on wikipedia
Then I should be able to see the word in the heading of the result page
It seems to be easier in understanding now, but still we will require to use data injection or some other method for matching the word in the then step-definition , if both the given & when step-definitions are in different classes, which is a very normal case in an automation framework.
So to solve the problem, simply make the output also as concrete as the below one:
When I search for word “Neema” on wikipedia
Then I should be able to see word “Neema” in the heading of the result page
Simply pass the input though given step and verify the output in then step . Input/Output can be change in respective steps, but notice they are always concrete .
Tester should have intention to make things easy but NOT complex, generalization is for developer they need to have their code work for everything in generalized manner. For an automation testers their code should run by passing concrete things in the testcases only.