Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:17:35+00:00 2026-06-15T08:17:35+00:00

My scenario is: public class ExampleTest extends AbstractExampleTest { @Test(dependsOnMethods={someMethodFromAbstractExampleTest} public void firstTest() {

  • 0

My scenario is:

public class ExampleTest extends AbstractExampleTest {
    @Test(dependsOnMethods={"someMethodFromAbstractExampleTest"}
    public void firstTest() {
        // Assert
    }

    // here I would like to call CommonTests
}

public class CommonTests {
    @Test
    public void sharedTest() {
        // Assert
    }
}

The reason something like CommonTests exists, is that it will contain a repeated test sequence. The way I currently communicate information from ExampleTest to CommonTests is done via statics which seems to work, but probably not the best.

This works fine if I call CommonTests programmatically according to the TestNG documentation. The issue I have with that is the results aren’t logged within the runner of ExampleTest.

@Test
public void actionBasedTest(ITestContext context) {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();
    testng.setTestClasses(new Class[] { ExampleAction.class });
    testng.addListener(tla);
    context.getSuite().addListener(tla);
    testng.run();
}

The above is slightly better, but the reporting back is limited to something like “org.testng.TestRunner@####” and doesn’t expose the test methods run.

So my question is: can I run tests from another class(es) (not via inheritance) and get the results logged to the same listener?

EDIT: I want to avoid testng.xml.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:17:37+00:00Added an answer on June 15, 2026 at 8:17 am

    Answering your last question , you can run tests of any classes using a testng.xml which allows you to structure your tests any way you like. You can specify your listener in the suite tag and that would be the listener used for all your classes. Refer this for examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue Seems like the condition gets ignored. Here is my scenario: Source class public
Here is the scenario public class Connection { public virtual void close() { /*Some
I have some scenario like this: public class BaseClass { protected void protectedMethod(OtherObject object)
I have the following scenario: public class A { } public class B extends
I have a classic Order -> Order Row scenario something like this: public class
I have this scenario: One custom class (Customer) with some properties, like this: public
If i have the following scenario: public class Foo extends Baz{ private String banana
In the following scenario public class Parent1 { } public class Child1 extends Parent1
Application-Context is correctly setup! Heres my class scenario public interface IManager { public void
Here is the scenario: I have: public class RandomStringUUID { public RandomStringUUID() { final

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.