How to turn your automated test scripts into an "Automation Framework"?

How to turn your automated test scripts into an "Automation Framework"


I have heard many professionals saying they had been working on/maintaining automation framework but when I inquired further, I found out that they were just building automation test scripts rather.

Therefore, it would not be insignificant If I start from “what is called automated test script?”, so it is not more than a program/script that is written in any programming language like C# or Java to test a certain part of a feature/functionality with capability to determine whether the actual outcomes and the expected outcomes are the same.

Once you can automate a manual test through any tool and language, it is not sustainable enough no matter your automation scripts contain 100s of test cases but then how would you cater the following questions/points? (I have written just a few)

1)     How would you use specific part of your own script as a subset for some other scenario? Code re-usability? Otherwise you would end up duplicating your code

2)     What if new test cases are required to be added/deducted in already covered feature due to feature change? Code maintainability

3)     How would you customize your automation scripts in a way some parts can be executed according to the requirement without execution of complete code?

4)     How would you achieve high level of test reporting because if you run your automated script, you need to make sure it would not error out if one condition fails and continue execution and it should give summarize results of your test suite including number of passed and failed cases at the end?

 What makes test automation framework a framework?

Framework is an environment/platform with set of good practices for execution of automated tests, that is why I prefer to call it a “SYSTEM” in which tests would be automated. Therefore, it is meant to be expandable, maintainable, results friendly, and reusable.

Let’s take an example of Selenium Webdriver as it is one of the best open-source automation ‘tool’ Framework :) . If you have used it then you can relate that you can write and execute your test-cases by invoking user actions on various elements of your web application but it wouldn’t be feasible for you to cater the above listed points without making significant steps and embedding certain practices into your environment.

Perhaps you would say that you could implement “page object” or any-other pattern in Selenium Webdriver to make your code reusable but what about maintainability, parallel execution of code, summarized test reporting, or how would you make sure that the specific Class doesn’t error out and continue execution even if one of the assertion within a method has got failed while execution of a long script (by defining Try Catch block)? Think wiser!!!

Perhaps you need to make your environment cleverer and efficient by embedding tools like “TestNG” with Selenium Webdriver in order to have advantages that includes:

·        Generation of logs

·        Generation of HTML report of execution

·        Division of test-cases into groups

·        Parallel execution of tests

·        Prioritization of test cases via built-in annotation 

·        Execution of selective classes (class = collection of test-cases) through customized test suite

·       Intelligent code re-usability

·        And no need to be worried if any specific method (Test-case) fails within any of your class because execution doesn’t stop.

Let's see the code comparison between the two:

Code Structure in Selenium Webdriver

public class example{

//initializations

public static void main(String[] args) {

driver.get(url);

verifyTitle(); //method call

driver.quit();

}

public static void verifyTitle(){

// Code for the method

}

}

Code Structure with TestNG

public class exampleTestNG{

//initializations

@BeforeTest

public void setURL() {

// Code

}

@Test

public void verifyTitle(){

// Code for the method

}

@AfterTest

public void end(){

//code

}

}


Sample result of Selenium Webdriver (it will give errors like this while execution of a class even if you have defined try and catch block)


Sample result of Selenium Webdriver with TestNG

Sample HTML report in testNG

CONCLUSION

Hence, you can evaluate your automation environment based on the points that are mentioned in this article to assess whether your environment is eligible to be called a Framework/System or you are just managing bunch of scripts.

Secondly, you can ask the same mentioned questions and assess the available options to make your environment a Framework/Solution so that it can be sustainable, maintainable, extendable, reliable, and manageable.

Lastly, I have given some tips and brief demo of one of the best free tools "TestNG" to embed into your selenium environment to make those components available to you that are required for any legitimate automation Framework.

Remember! it is all about best practices..... :)

 


 

 

   

要查看或添加评论,请登录

Evelyn Jones的更多文章

社区洞察

其他会员也浏览了