Skip to main content

Selenium TestNG with Framework

 
Selenium Testing Frame work

Selenium TestNG with Framework

TestNG is a testing framework inspired from JUnit and NUnit. But introduce some new functionality that makes it more powerful and easier to use. It is an open source test framework where NG of TestNG means Next Generation. TestNG is like JUnit but it is much more powerful than JUnit but still, it’s inspired by JUnit. It is design to better than JUnit, especially when test integrated classes. Pay special thanks to Cedric Beust who is the author of TestNG.
TestNG eliminates most of the limitations of the older framework. Gives the developer the ability to write more flexible and powerful tests. With help of easy annotations, group, sequence & parametrize.

Advantages of TestNG

There are a number of benefits but from Selenium perspective, great advantages of TestNG:
It gives the capacity to provide HTML Reports of execution
Annotations made testers life easy
Test cases can Group & Prioritized easier
Parallel testing is possible
Generates Logs
Data Parameterization is possible

Test Case Writing

Write a test in TestNG is quite simple and involves below steps:
Step 1 – Write the business logic of the test
Step 2 – Insert TestNG annotations in the code
Step 3 – Add the information Example the class names, methods names, group names etc in a testing.XML file
Step 4 – Run TestNG

Annotations in TestNG

Before Suite: The annotated method will run before all tests in this suite have run.
After Suite: The annotated method will run after all tests in this suite have run.
Before Test: The annotated method should run before any test method. Belongs to the classes inside the tag will run.
After Test: The annotated method should run after all the test method. Belongs to the classes inside the tag have run.
Before Groups: The list of groups that this configuration method will run before. This method is the guarantee to run shortly before the first test method. Belongs to any of these groups is invoke.
After Groups: The list of groups that this configuration method will run after. This method is a guarantee to run shortly after the last test method. Belongs to any of these groups is invoke.
Before Class: The annotated method will run. Before the first test method in the current class is invoke.
After Class: The annotated method will run. After all the test methods in the current class have run.
Before Method: The annotated method will run before each test method.
After Method: The annotated method will run after each test method.
Test: The annotated method is a segment of a test case.

Benefits of using Annotations

It identifies the methods it is interested in by look up annotations. Hence method names are not restricted to any pattern or format.
We can pass extra parameters to annotations.


Comments

Popular posts from this blog

AutoIt in Selenium Webdriver

    AutoIt in Selenium Web driver Selenium is an open source tool. That designed to automate web-based applications on different browsers. But to handle window GUI and non-HTML popups in the application. AutoIt required as these window based activity are not handled by Selenium . What is AutoIt? AutoIt v3 is a freeware scripting language designed for automating. the Windows GUI and general scripting. the combination of keystrokes, mouse movement and window/control manipulation to automate tasks. It is way not possible or reliable with other languages. AutoIt is very small, self-contained and run on all versions of Windows. The face with no annoying “runtimes” required. In layman’s term, AutoIt is another automation tool. Selenium used for Desktop Automation rather Web Automation. It is a powerful tool. It does not automate desktop windows, button & for. it automates mouse movements & keystrokes too. Selenium IDE recording capability generat...

Jenkins used in maven

  What is Jenkins? The Jenkins is the most important open source continuous process of the combine with another tool. It is cross-platform and it can be used on Windows, Linux, Mac and Solaris environments. It is composed in Java. Jenkins most important usage to check the progress any job which can be any application state.  It stimulates preconfigured actions when an individual step occurs in tasks. The Jenkins allows us to take 1 more step further, and allow us to automate this execution of test cases. A little more work, you can configure such that your tests execute every time after deploys a new build. Checks in code Jenkins build a execute unit tests, now deploys the application to test environment. Jenkins builds and then executes your tests on the newly deployed application. This is essential the CI process that others have mentioned. At this point, the only thing that you need to real worry is the writing of your test automa...