- Testing Framework
A framework usually takes away the grunt work out of running the tests, generating reports. The most common frameworks used in automation is JUnit & TestNG. Moreover you can design your own framework.TestNG is a preferred framework for testers. It is inherited from JUnit and NUnit. It allows you to group test cases easily which is not possible in JUnit.Using a framework like TestNG gives you to flexibility to define execution order, dependency on other cases/skipped if one or more cases fail, etc.It also has automatically to generate test reports in both HTML and XML formats.
- Retrieving test data from external files
Instead of hard coding, it will be better to keep test data is kept in external files and read it through your script.For example : to compare data, use for data-driven testing or it can even be used for Assertion/Validation purposes.Keeping test data in external files is always a good approach. It gives the feasibility to make changes in just one file whenever test data changes rather than tampering your entire code.
- Modularize your code
Always follow “Divide and conquer”.Smaller the size of code component, easier it is to maintain.It will provide more reusability and separation of concerns. It becomes even more beneficial when working in teams for others to understand the code easily.
By: Ravi Beck