Sunday 2 October 2016

How to Configure TestNG with Android Studio

In our previous tutorial we have learnt about Junit Testing framework  and now in this we will get to know about one more powerful testing framework called TestNG. TestNG framework as some different functionalities which makes it more powerful testing framework.
What is TestNG Framework?
TestNG is a testing framework developed from inspiration of Junit and Nunit with additional features making is more effective and simple for use. It is a powerful automation testing framework where NG Stands for Next Generation. It gives developers power to write more flexible and powerful test cases.

Features of TestNG –
1.It allows you to use new features of Java programming language while writing test cases.
2.Like Junit it provides annotations to identify your test methods and flow of execution.
3.Separates compile time test code and run time configurations.
4.Provides powerful test case execution support.
5.Allows you to perform multithreading testing.
6.Initially It was designed for unit testing but now allows load testing , parallel testing etc.

There is so much more in this and  we will explore more and more when we start coding. But it is very important to learn basics about Testing frameworks before writing your test cases as selection of right framework is like building pillar for your automation framework.

How to Setup TestNG –

1. Create and Android Project or open your existing project
2. Go to app -> build.gradle
3. Copy the below line of code in your dependencies section.
       testCompile 'org.testng:testng:6.9.10'

4. Click on Sync
5. Once you get build successful message then you are ready to go.


  1. Hi,
    How to run TestNG suite XML file after configuring this?

    1. Hi,

      How to run multiple test cases using testNG? Where I will get testng.xml file in android studio?

      Thanks in advance