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.

Order for DependsOnGroups has changed after TestNg 7.4.0

See original GitHub issue

TestNG Version

7.5 not working 7.4 works

Expected behavior

s3 s1 s2

Actual behavior

s1 s2 s3

Is the issue reproducible on runner?

  • Maven
  • Eclipse
  • IntelliJ

Test case sample

Here is an example for BeforeSuite, but the same problem exists for all configuration methods. The same issue also for dependsOnMethod

    @BeforeSuite(groups = { "g1" })
    public void s3() {
        System.out.println("s3");
    }

    @BeforeSuite(groups = { "g2" }, dependsOnGroups = "g1")
    public void s2() {
        System.out.println("s2");
    }

    @BeforeSuite(groups = { "g2" }, dependsOnGroups = "g1")
    public void s1() {
        System.out.println("s1");
    }

    @Test()
    public void test3() {
        System.out.println("test3");
    }

I have tried to find the commit where the fault was introduced, but my IDE did not like to switch gradle version and I’m new at gradle.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:29 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
martinaldrincommented, Oct 27, 2021

Hi @krmahadevan I agree unit tests are lacking in this area.

But in my opinion it is not unclear, because of.

  1. The sorting was working in the same way for groups and methods in earlier versions.
  2. The include/exclude working in the same way for groups and methods in earlier versions. up 7.4 broken in 7.5
  3. Include/Exclude of methods and groups are specified in a similar way in the suite.
  4. Similarity between the annotation makes it easier to use, if you can expect similar behavior.
  5. Documentation does not say anything about that groups must be defined in a suite xml.
  6. A if statement was added in the generic sorting mechanism that skipped the sorting for some methods.
  7. A Behavior was change, will introduce a non backward compatible change that will affect many users.
0reactions
martinaldrincommented, Nov 2, 2021

@juherr I think it works pretty well for everything except for one that was recently implemented after 7.4 release. With my changes I think groups starts to work as it did before

I also believe that current implementation is quite dangerous, adding dependsOnMethod internally could definitely give some strange behavior since it can interfere with users configuration. Adding an internal priority would be much nicer here, since that can never interfere with the user configuration and just make a more soft sorting that users can override easily.

                  if (!equalsEffectiveClass(m1, m2) && !dependencyExists(m1, m2, methods)) {
                    Utils.log("MethodInheritance", 4, m2 + " DEPENDS ON " + m1);
                    m2.addMethodDependedUpon(MethodHelper.calculateMethodCanonicalName(m1));
                  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tests are not running in correct order if parallel="classes" is ...
Kindly have a look. Above scenario is working fine: If TestNG 6.14.3 is used; Or if parallel="tests" is used with TestNG 7.4.0 ......
Read more >
TestNG 7.5 released !! - Google Groups
TestNG 7.5 would be the last of the TestNG releases that would run on JDK8. ... GITHUB-2664: Order for DependsOnGroups has changed after...
Read more >
TestNG not running tests in testing suite - Stack Overflow
In my case, the @Test annotation was imported automatically by IDE as import org.junit.Test . After changing it to import org.testng.annotations.
Read more >
Documentation - TestNG
A test method is a Java method annotated by @Test in your source. ... By default, TestNG will run your tests in the...
Read more >
Deprecated List (testng 7.4.0 API) - Javadoc.io
org.testng.TestNG.addListener(Object). Use addListener(ITestNGListener) instead ... since 5.1. org.testng. ... This method is deprecated as of "7.4.0".
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