Practical Tips for Writing Automated Tests When You’re Just Starting Out
When first starting to write automated tests, you may notice that you’re getting too bogged down by the nuances of the code, and it may be challenging to see the bigger picture. You may notice that often lost track of where you were when you have had to context switch to another task.
Well, fear not, some strategies have helped me to write tests faster, and I am sharing them with you.
1. Make a list of all of the items that need to be verified
Manual testers make lists called a Test Checklist of the features that they will be testing to keep their thoughts organized. You can employ this strategy too to plan your tests. List everything that you think will need to be automated. Think of positive, negative scenarios, are there any edge cases that you may not have found?
2. Review the list of items to be tested
Before writing any code that runs an automated test, take the time to review the test cases that you’ve written in your test checklist. Are the items in your test checklist meaningful from a user’s perspective? Is it practical? When you take the time to review your test cases, you may detect gaps in your test coverage before writing a single line of automation code.
3. Write stubs of classes and methods needed by your tests before getting too deep in the code
Start with a single test and then write the names of classes and the functions that will be required to complete the use case that you are automating. Use this moment to get your thoughts organized before actually coding.
4. Run the automated tests while coding
Keep running the run automated test as you code so that you can easily verify that you have not broken any of your previous tests.