All IT Courses 50% Off
QA Tutorials

Dependency Testing

Dependency Testing, it is a testing technique in which an application’s requirements are pre-examined for an existing software, initial states in order to test the proper functionality. Dependency Testing allows single test method which depends on one or more test methods. This is important feature when our program relies on ordering of test. Test Method such as launching a web server must execute before deploying code to an environment.

A test method thus launching web server must run before deploying code to an environment. The dependent test methods ie, launch, which needs to pass before executing the calling Test method deploy. If launching a web server fails, then there is no server for testing the application. With dependency testing our test report returns one failure and also has several skips. Without dependency testing our test report returns a cascade failure due to the failed launch method. A cascade failure is similar to a waterfall of failures, if one test method fails then it causes the remaining tests also to fail. The cascade failure produces a misleading Test Report because the calling test method ie deployment and remaining tests which were not executed.

TestNG Methods

1. DependsonMethods() attribute

The dependsonmethods attribute is an attribute of @test annotation. TestNG enables our program to say an array representing a Test method depends on.

Dependency Testing

Consider a TestProject which explains DependsOnMethods. We will be using DependsOnMethods as

1. Create a free account with TestProject

2. Signin the TestProject.

3. Click the new button.

4. Mobile, web and code are available as Test types.

https://blog.testproject.io/wp-content/uploads/2019/09/3.3_Test-Types-512x309.jpg

2. DependsOnGroups

We may specify our test depends on any other groups, where it is helpful to have multiple methods and they are grouped together. We can simply specify the group test which depends on, rather than specifying the main list of all methods.

All the earlier defined methods are part of group named tests. The methods depend on pre-tests group. We have also cleanup method that depends on the tests group.

@Test(groups = “pre-tests")
 
public void init() {
System.out.println("init resources");
}
 
@Test(groups = "tests", dependsOnGroups = "pre-tests")
public void insert() {
System.out.println("inserting demo data");
}
 
@Test(dependsOnMethods = "insert", groups = "tests")
public void select() {
System.out.println("selecting demo data");
}
 
@Test(dependsOnMethods = "select", groups = "tests")
public void update() {
System.out.println("updating demo data");
}
 
@Test(dependsOnMethods = { "insert", "update" }, groups = "tests")
public void delete() {
System.out.println("deleting demo data");
}
 
@Test(dependsOnGroups = "tests")
public void cleanup() {
System.out.println("closing resources");
}
}

The output of test execution is:

init resources
inserting demo data
selecting demo data
updating demo data
deleting demo data
closing resources

This test can also be done together in a suite by creating an XML file.

From all the examples, the dependency testing is a technique where application’s requirements are pre-examined for existing software in order to achieve desired functionalities. This examination will take care two factors faults and defects existing in the application. Just like other application or tools, software has some impacted areas such as compatibility user-interface and importantly there will be no such as compatibility. User-interface and most importantly there should be no such vulnerability for information breach.

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Check Also
Close
Back to top button
Close
Close

Get Python Course
worth 499$ for FREE!

Offer valid for 1st 20 seats only, Hurry up!!

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

H2kinfosys Blog will use the information you provide on this form to be in touch with you and to provide updates and marketing.