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:

  • -Complexity
  • -Functionality
  • -Cost
  • -Common technology
  • -Advanced features
  • -Meeting requirements
  • -Maintainability 
  • -Integration with other frameworks for future purposes
  • -Ability to handle the current issues
  • -Ability to offer high extensibility
  • -Ability to create libraries
  • -Mobile support

    Choosing An Automation Framework

  • If your project doesn’t have an automation framework, then your first step is to understand the project and testing requirements in detail. After understanding the requirements and breaking them into test scenarios, it’s time to do research on testing frameworks to see the different options that are available in the market and suitable for your testing requirements. There are many open source, or licensed frameworks that are available in the market. Check for the features available in each kind of framework and determine which one meets your testing requirements. If you're considering an open source framework, then check out the following pros and cons for an open source framework such as Selenium Webdriver.
  • Open Source Frameworks 
  • Pros: 
  • -They're easily available.
  • -They support almost all kinds of browser testing.
  • -They support many languages such as Java, Ruby, and Python for developing automation code.
  • -They're free products. 
  • -They support almost all types of web applications.
  • -Depending on the project, many open source frameworks support the development of keyword, data, and behavior driven frameworks.
  • -Many frameworks are highly extensible because new libraries are usually added every year. 
  • -Popular frameworks have continuous development. 
  • -Some testing frameworks support parallel testing.
  • -Some are very easy to install and can be done simply by adding libraries to your project path. 
  • -Most of the testing frameworks use many annotations which help write strong test cases.
  • -Some of the frameworks are easy to configure in Maven cycle such as TestNg, Karate, and JUnit.
  • -Some frameworks support asynchronous testing such as Mocha. 

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.

Licensed Frameworks

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.

Identifying the Correct Tests for Automation

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.

Checking for Reusability of Code

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.

ilya-pavlov-87438.jpg

Debugging Automation Code 

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:

    • -Add Print statements at logical ends, as this will help you find bugs either in the test code or developer’s code.
    • -Write comments for the code at the top of the function, and at logical statements for lower/detail level code.
    • -Use debugger to find the defects in your code.
    • -Write documentation for overall test class functionality.
    • -Give meaningful names to variables to help with debugging and understanding.
    • -Perform self reviews and peer code reviews before actually merging the code with master.
    • -Prepare the data considering different scenarios like boundary conditions, negative test cases, invalid data, and positive scenarios to find the maximum amount of defects in development code.
    • -Consider the cyclomatic complexity of the code.
    • -Breakdown your test code if it's covering too many scenarios, and make it simple, maintainable, and easily understandable.

Good Practices to Follow in Automation

  • Following industry standards when developing code: Coding standards are simple rules and guidelines followed during your code implementation that help provide high readability and better visibility when searching for errors. Some general coding standards that are followed are camel case variable names and the use of curly brackets (i.e. {) followed by tab, ({) after conditional statements. Check the coding standards followed in your organization and implement your code using those standards. 

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.

Conclusion

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. 


Author

Meera Honde

Currently a Lead Automation Engineer, Meera loves to solve problems. Her hobbies include traveling, driving, cooking, and watching movies.


Testing With Karate Knocks

READ MORE

How to Develop An Automation Framework - Part 2

READ MORE

Try Dev Box Testing And See How Much Time You Can Save

READ MORE