How to write good TestCase?
Ministry of Testing
Case Study:
Some good docs that break apart the basic stuff, like how to write a good test case and how to organize and use them effectively?
-- Anonymous
Recommendation 1:
What are you trying to do? Is your company wedded to test cases? My experience is that test cases on their own tell you things you already know. That is 25% (at a maximum) of what could happen with your product. Who or what is investigating the other 75%? (Known Unknowns, Unknown knowns, Unknown Unknowns). Sure you could write test cases for things you expect. What about the things you donât expect, once the product is built? No amount of test cases will tell you that. Personally I prefer high level acceptance criteria rather than all the detail of how to test it (which is great for a computer but boring as hell for anyone to execute) and then I supplement this with exploratory testing.
Are your developers using BDD (note I said âdevelopersâ, BDD is not a tester framework, it is BDD not BDT). In that case sure, assist them by helping define the requirements, not the testing, via Gherkin. That is a valuable action and part of 3 Amigos. So, if youâre talking about the Gherkin for BDD to help the developers deliver what was requested itâs... Given When Then. The Given should not contain many Ands, preferably none. For example, âGiven I am on the checkout page with a populated basketâ is cleaner than âgiven I am on the homepage and I log in with valid credentials and I place a product in the basket and...â endlessly. When is a simple action; âwhen I click Xâ (though you want to be generic like âwhen I click the submit buttonâ not âwhen I click the Read More linkâ since the text may change or not always be in English). âThenâ should be short too. âThen I am taken to the confirmation screenâ or âthen I am presented Y informationâ. You can have additional assertion criteria such as âand my card is charged for the transaction And the database records the transactionâ. This can be asserted. If you have more âand whenâs that gets messy. Try to make those a new test case. Never ever use OR. That should be a separate test case.
Now back to why test cases may not be the answer... test cases are great for computers but not if something unexpected happens, which is what you really should be looking at. Not expected stuff but the unexpected stuff. If you only do test cases you will miss loads. Please donât wed yourself to test cases.
-- Mike Ruttenberg
Recommendation 2:
Normally my preferred way is to write for a feature/function one detailed "Master" test case (which I flag with "(M)" add the beginning, so I can also filter them easily, e.g. for a smoketest), there I write step by step the easy happy path in it, next to it I write then all special TC but then I only write the special thing to it, so I don't copy all the basic stuff all the time.
--Andreas
Reference:
Last updated

