priority behavior changes when i relocate/rename class

54 views
Skip to first unread message

Michael Grove

unread,
Jul 25, 2016, 5:30:25 PM7/25/16
to testng-users
I have a class called ProviderOrgLDAPConfigurationTest in package com.hp.csa.unit.gui.smc.organizations, with a single test method with signature

@Test(priority = -1000)
public void configureLDAPForProviderOrgIfRequested() throws Exception {

When I run my suite, which has this TestNG suite file:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="CSASmcGuiUnitTestSuite" >
<test name="CSASmcGuiUnitTests"   >
<packages>
<package name="com.hp.csa.unit.gui.smc.*" >
<exclude name="com.hp.csa.unit.gui.smc.dashboard.codar" />
<exclude name="com.hp.csa.unit.gui.smc.releaseautomation.*" />
</package>
</packages>
  </test>
</suite>

The test method runs first, as I intend it to.  The majority of my ~80 tests under the package specified in the suite file do not specify priority at all; one specifies priority = -1.  The tests all run in the order I expect - first the -1000 runs, then the -1, which is in a OrganizationsTest in the same package, then all the tests that don't specify priority (again, ~80, in various packages) run in a seemingly random, but consistent between runs, order.

If I do nothing else but rename the class to CSAProviderOrgLDAPConfigurationTest, it no longer runs first.  Other tests in different packages, that don't specify priority, now run first.

I first noticed this when, in addition to the rename, I also changed the package to com.hp.csa.unit.gui.smc.organizations.csa.  I couldn't figure out why that would matter, but assumed the package change was the issue, so I put the class back in its original package.  But unless I additionally renamed it back to its original class name, this test method with a priority of -1000 would not run first.

In addition, the test with priority of -1 would not run 2nd as it should unless I addressed the -1000 problem by renaming it back to its original name.

I'm using 6.9.6.  Also tried 6.9.12, no help.

Any ideas?

Thanks.

-mike

⇜Krishnan Mahadevan⇝

unread,
Jul 30, 2016, 9:38:13 AM7/30/16
to testng...@googlegroups.com
Mike,

Would you be able to create a sample project that can be executed to recreate the problem ? If there was a reproducible case, I can try to find out what is the cause of the behaviour you are experiencing.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Michael Grove

unread,
Aug 1, 2016, 9:47:13 AM8/1/16
to testng-users
I've uploaded an Eclipse project showing the problem.  You'll just need to update the paths to testng-6.9.12.jar and jcommander-1.48.jar for your local environment, then run the single suite file included.

While working to create this sample project it seemed to me that priority ever working for me was purely accidental.  Whether the test with priority -1000 went first was totally dependent on what other test classes I had in my environment.  As I was copying in tests from my actual project, the test with priority of -1000 did not go first until I had copied in a certain number of those other tests.  E.g. if I relocate everything out of the smc package except for CatalogsTest, OrganizationsTest, ProviderOrgLDAPConfigurationTest, and SmcGuiUnitTest (i moved everything else to a package outside of smc) then the test with priority -1000 does not go first.

With the attached project, the test with priority -1000 does go first (matching my expectations), the test with priority -1 does *not* go second (as I would hope/expect it would), and every other test has priority unspecified (so 0) and I don't care in what order it runs (though I'd like all test methods in a test class processed together before we proceed to the next test class, which is what happens).

If I relocate ProviderOrgLDAPConfigurationTest to the csa subpackage, com.hp.csa.unit.gui.smc.organizations.csa, the test it contains with priority -1000 no longer goes first.

If I remove the priority = -1000 from the test (back in its original location), it no longer goes first (matching my expectations) though the test with priority -1 doesn't go first either (not matching my expectations).

Hope this helps track down the problem or what I'm doing wrong.

Thanks.

-mike
CSAPriorityProblem.zip

Michael Grove

unread,
Aug 8, 2016, 4:22:32 PM8/8/16
to testng-users
If a different format than an Eclipse project would be helpful, please let me know.  I can create a ZIP of a Maven project, for example, if that'd be more helpful.

Thanks.

-mike
Reply all
Reply to author
Forward
0 new messages