In the simplest terms, automation is the test code developed to reduce human efforts whenever there are any changes in the system and the system then needs to be revalidated against new changes.
Generally, in application testing, a system validation is performed by running regression test suites every time. Automation is a great way to perform regression testing as well as validate the system against new changes. It also helps to reduce human efforts and manual execution errors by running the regression suite through automation every time. If automation is done correctly, it increases testing scalability, decreases huge manual efforts, reduces execution time, and reduces costs for testing efforts, which then decreases overall project cost. The following are some good points for any automation engineer to consider while developing automation framework or working on any specific automation framework:
Cons:
-Since they're open source frameworks, there might be a lack of available technical support.
-Some open source frameworks aren't cross platform.
-Some have issues with mocking, so you may need to add Mockito.
-Some aren't easy to maintain.
-Some may not support additional libraries or extensions.
Therefore, while selecting your testing framework, consider all important factors. Check for compatibility, extensibility, and reliability for open source frameworks.
Some of the examples of open source framework are JUnit, TestNg, Mocha, Karate, NUnit, MUnit, and Robot.
If you choose to go for licensed frameworks, check out the following pros and cons:
Pros:
-Technical support is easily available.
-Most licensed frameworks are highly secure.
-Most licensed frameworks are well documented and provide trainings, making learning easy.
-They're reliable to install in any environment.
-Some frameworks provide high extensibility so you can start working while development is in process, such as QTP, which provides features like descriptive programming to solve object recognition issues.
Cons:
-Can cause an increase in the overall cost of your project.
-Some frameworks support very specific programming languages, for example, QTP only supports VB or C++.
-For some frameworks, extensibility and compatibility with other frameworks can be hard. Therefore, when you want to migrate code from other frameworks or configure other frameworks within your framework, a lot of change is required.
Some examples of licensed automation frameworks are HP’s QTP ( currently called UFT - Unified functional Testing), IBM’s Rational Functional Tester, and Micro Focus’s Silktest.
It's always good practice to identify the correct tests for automation. This helps reduce automation efforts with high maintainability, reduce duplicate efforts, and use automation effectively. Always choose tests from regression test suites that meet the following criteria:
-Tests that test after any change is made in the application.
-Tests with high risks.
-Tests that are difficult to execute manually.
-Tests that take more time to execute because they need to execute for all changes.
-End to end test scenarios that verify that the application isn't breaking after new changes are made.
-Tests that may fail with different hardware or software configurations.
-Tests that need multiple data sets.
-Tests that cover user acceptance scenarios.
-Tests that may fail because of human error.
It's extremely important to check your code for reusability because it helps to avoid duplicate code as well as maintain automation code when the application grows. Code reusability can be implemented by following some good practices such as developing utility functions, separating libraries, data files, and putting common resources together. In Selenium Webdriver, use the page object model design pattern to support reusability, inheritance, encapsulation, data abstraction, developing libraries, or common utility functions.
The page object model design pattern allows you to define each web page as one Java object/class. It also implements object oriented concepts like polymorphism and overloading/overriding to make the code more maintainable and readable.
No code is bug free, but to make it as clean as possible, and to find the maximum amount of defects, you can follow these simple strategies:
Using different testing frameworks in the same automation code: Configure your automation framework in such a way that it can support multiple testing frameworks in your automation.
Integrating your automation code with different frameworks: Before writing your tests and preparing test data, think of possible ways that they can be bundled with other tests. Implement different testing frameworks within your testing framework if needed.
Things to keep in mind when checking for high code maintainability:
-Correct code configuration.
-All page object related code should be under the SRC/Main/Java package.
-Breaking down multiple objects that we can filter with the same functionality into sub packages.
-All packages under main/sub packages should be created or named as per functionality.
-Each class name should have a meaningful name.
-All test classes should be under a SRC/Test/Java package. For individual classes and sub packages, the same rules apply.
-Each test class should end with Test in its name.
-For all the resources, there should be a SRC/Test/Resources package.
-All data files should go into the SRC/Test/Resources/data package.
-All property files should be in the resources package.
-All common utility functions should be added to the libraries or utilities package.
I hope you found this article to be helpful! I'm interested to hear how these tips work out for you. Try implementing what you've learned from this article into your practices and let me know what you observe.