question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inheritance + dependsOnMethods

See original GitHub issue

Test case sample

public abstract class Base {
    @Test
    void test() {
        assertEquals(getClass().getSimpleName(), "Test1");
    }
}

class Test1 extends Base {
    @Test(dependsOnMethods = "test")
    void otherTest() {}
}

class Test2 extends Base {
    @Test(dependsOnMethods = "test")
    void otherTest() {}
}

Expected behavior

image

Actual behavior

image

TestNG Version

7.4.0 I do not know if it worked in the past

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

I do not understand if actual behavior is intended or is a bug, but would that be ok to change it? if not, is there any option that I could override it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
krmahadevancommented, Oct 18, 2021

@juherr - To be honest, I am not sure what should the behaviour be. I was just gathering information from @karolrom-intel so that we can figure out what to do with this. The current behaviour in my opinion is counter intuitive.

0reactions
juherrcommented, Oct 18, 2021

@krmahadevan I think the test inheritance is often used like “import tests from parent” (copy/paste). About a potential fix, it just means that the test name depends on the instance and not only on the declaring class. I will be curious to see if changing it will break tests or not.

Do you see a valid use case for the current behavior?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are TestNG Dependent Tests and How to ... - Tools QA
In inherited dependent test methods in TestNG, we create dependency among the methods that belong to different classes, and one of the classes ......
Read more >
TestNG Dependent Tests with Examples - HowToDoInJava
Tests with Single Test Dependency. Use dependsOnMethods to create a sample test method that depends on another test method of the same class....
Read more >
TestNG dependsOnMethods from different class - java
DependsOnMethods cannot be used from different class ,To resolve this we can use dependsOnGroups; ... Using dependsOnGroups and inheritance
Read more >
Using annotation inheritance for testing - Otaku – Cedric's blog
Here is how I would write this test using TestNG: @Test public correctVM() {} @Test public serverStartedOk() {} @Test(dependsOnMethods = { "correctVM", " ......
Read more >
How to Run a Test only if Dependent Test Method Has Passed
Test; public class DependencyDemo { @Test(dependsOnMethods = { "TestB", ... Here's an example where the dependent methods are part of an inherited class....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found