DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Apex Testing: Tips for Writing Robust Salesforce Test Methods
  • Why Do We Need to Keep Our Builds Green?
  • Mocking Dependencies and AI Is the Next Frontier in Vue.js Testing
  • Mastering Test Code Quality Assurance

Trending

  • Transforming AI-Driven Data Analytics with DeepSeek: A New Era of Intelligent Insights
  • Problems With Angular Migration
  • How To Replicate Oracle Data to BigQuery With Google Cloud Datastream
  • Measuring the Impact of AI on Software Engineering Productivity
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. TestNG Depedency Test – Multiple Test Method Dependency

TestNG Depedency Test – Multiple Test Method Dependency

By 
Jagadeesh Motamarri user avatar
Jagadeesh Motamarri
·
Sep. 22, 13 · Interview
Likes (0)
Comment
Save
Tweet
Share
40.5K Views

Join the DZone community and get the full member experience.

Join For Free

Dependency is a feature in TestNG that allows a test method to depend on a single or a group of test methods. This will help in executing a set of tests to be executed before a test method.

The dependency on multiple test methods is configured for a test by providing comma separated dependent test method names to the attribute dependsOnMethods while using the Test annotation.

The following example shows a test class where process() test method depends on multiple test methods start() and initi() of the same class.

Code

?
package com.skilledmonster.example;
import org.testng.annotations.Test;
/**
* Example to demonstrate TestNG multiple dependency method execution
*
* @author Jagadeesh Motamarri
* @version 1.0
*/
public class MultipleDependencyTest {
@Test
public void start() {
System.out.println("Starting the server");
}
@Test(dependsOnMethods = { "start" })
public void init() {
System.out.println("Initializing the data for processing!");
}
@Test(dependsOnMethods = { "start", "init" })
public void process() {
System.out.println("Processing the data!");
}
@Test(dependsOnMethods = { "process" })
public void stop() {
System.out.println("Stopping the server");
}
}

Output


TestNG Depedency Test - Multiple Test Method Dependency - Output

As seen in the above console output, process() method executed after start() and init() methods are executed and like wise stop() method is executed after process()  method is executed.

Download

[GitHub]

Testing Test method Dependency TestNG

Published at DZone with permission of Jagadeesh Motamarri, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Apex Testing: Tips for Writing Robust Salesforce Test Methods
  • Why Do We Need to Keep Our Builds Green?
  • Mocking Dependencies and AI Is the Next Frontier in Vue.js Testing
  • Mastering Test Code Quality Assurance

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!