New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to add priority on a class in TestNG xml #1324
Comments
Everything in an annotation is supposed to be doable in xml too. So, the request seems legit IMO ;) |
@krmahadevan This request could be easy if you want to have a look on it ;) |
@juherr - I will take a look at this one. I was away for a couple of days due to a personal emergency. |
If you remove the Scenario : Test classes have one or more
|
@juherr - I would like to understand the expectations of this fix. Currently when Should we change TestNG to start honouring the newly proposed i.e., consider the below example import org.testng.annotations.Test;
public class MyTests1 {
@Test(priority = 1)
public void test1() {
System.out.println("test1 from " + getClass().getSimpleName() + " class");
}
@Test(priority = 2)
public void test2() {
System.out.println("test2 from " + getClass().getSimpleName() + " class");
}
} public class MyTests2 {
@Test(priority = 1)
public void test3() {
System.out.println("test3 from " + getClass().getSimpleName() + " class");
}
@Test(priority = 2)
public void test4() {
System.out.println("test4 from " + getClass().getSimpleName() + " class");
}
} <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Suite" verbose="2" parallel="tests" thread-count="10">
<test name="Some Workflow Tests" parallel="none" preserve-order="true">
<classes>
<class name="org.rationale.emotions.github.issue1324.MyTests1" priority="2"/>
<class name="org.rationale.emotions.github.issue1324.MyTests2" priority="1"/>
</classes>
</test>
</suite> So we should execute them as below ?
Would appreciate if you could please help shed more light around this. Also what should be the execution order for an xml such as the one below ? <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Suite" verbose="2" parallel="tests" thread-count="10">
<test name="Some Workflow Tests" parallel="none" preserve-order="true">
<classes>
<class name="org.rationale.emotions.github.issue1324.MyTests1" priority="1"/>
<!--Here SomeOtherTest is not having any priority in the xml. So what should its default priority be-->
<class name="org.rationale.emotions.github.issue1324.SomeOtherTest"/>
<class name="org.rationale.emotions.github.issue1324.MyTests2" priority="2"/>
</classes>
</test>
</suite> Also should |
In fact, I understand the need to override compiled things, like So, my first idea was to add Another idea (which can complete or replace the first one) is using XML, which is already supposed to be a way to order tests: <test name="Some Workflow Tests" parallel="none" preserve-order="true">
<classes>
<class name="org.rationale.emotions.github.issue1324.MyTests1">
<include name="test1"/>
</class>
<class name="org.rationale.emotions.github.issue1324.MyTests2">
<include name="test4"/>
</class>
<class name="org.rationale.emotions.github.issue1324.MyTests1">
<include name="test2"/>
</class>
<class name="org.rationale.emotions.github.issue1324.MyTests2">
<include name="test3"/>
</class>
</classes>
</test> Expected output: The current implement won't work because of @cbeust WDYT? |
Intuitively, I think I'd expect |
What do you mean by:
Currently, Another option is having Both options, or only one, could be implemented. |
@cbeust What do you prefer?
|
In doubt, and since this problem has been pretty rare so far, I'm inclined to do nothing. |
ok |
Hi Everyone, |
@goelgautam1994 - I would suggest that you submit a new issue, with some test code that can be used to recreate the problem. |
Hello, What Juherr suggested in # 1 above about putting priority into xml would be of enormous benefit in situations that I have found my company in. We have some selenium tests that can not run in parallel, and are functional different tests. As such our manager does not like the idea of putting them all into one class and using the @test priority tag. Here is a small snippet of our main test suite. The idea for us being able to use priority in the xml is to instruct testng to run one of the non parallel tests as soon as a thread is available. Currently without having priority in code usually see's these tests as the last running test, and if they got unlucky to get a freed up thread, they could take up to 30 minutes to finish up as the only running tests of the 10 parallel. <suite name="Regression" parallel="tests" thread-count="10">
<listeners>
<listener class-name="admin.RetryListener" />
</listeners>
<test name="CompileTest">
<classes>
<class name="admin.CompileTest" />
</classes>
</test>
<!-- +++++++++++++++++++++++++++++Invoicing++++++++++++++++++++++++++++ -->
<test name="TaxRulesInvoices">
<classes>
<class name="tests.Invoicing.RedraftInvoice" priority="1"/>
<class name="tests.Invoicing.CancelInvoice" priority="1"/>
<class name="tests.Invoicing.CreateInvoiceCancelTaxesAndDiscounts" priority="1"/>
</classes>
</test>
<test name="USSalesTaxInvoices">
<classes>
<class name="tests.Invoicing.GenerateCSVExtract" priority="1"/>
<class name="tests.Invoicing.ApproveInvoice" priority="1"/>
</classes>
</test>
<test name="VATInvoices">
<classes>
<class name="tests.Invoicing.RejectInvoice " priority="1"/>
<class name="tests.Invoicing.GeneratePDFExtract" priority="1"/>
</classes>
</test>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!--+++++++++++++++++++++++++++++++++++++++++++++ Assignment +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<test name="AmendAssignmentTest">
<classes>
<class name="tests.Assignments.AmendAssignmentWF3" />
</classes>
</test>
<test name="ApproveHeadCountTrackingAssignmentTest">
<classes>
<class name="tests.Assignments.ApproveHeadCountTrackingAssignment" />
</classes>
</test> This example is one of many my company runs into with concurrence issues where we see our regression tests only running 1 or 2 threads out of 10 for up to 30 minutes after the other several hundred tests have passed. Is adding priority to the xml out of the question? |
@goelgautam1994 Did you fix your problem or created an issue for it ? |
Class level priority is throwing error "Attribute priority is not allowed here" Please advice what need to be done for this? |
This was never implemented (Notice how the bug was closed as "Wont fix").
So there's no fix for this.
… |
Is there any way to change priority runtime? @cbeust |
@reemav - Please make use of an |
@krmahadevan , could you please provide an example of doing it with priority and how runtime I will be able to change the priority ? I saw most of the examples on Dataprovider . |
This was good feature to have. Not sure why this wasn't implemented. |
Yes, it would be a really great feature to have, adding priority to classes in XML. |
Following by #1309 it would be helpful to have possibility to add priority on a class in TestNG xml file in case we have several classes within
<classes></classes>
tag. What I mean:It's would be some kind of improvement and could help to avoid appearing similar issues (#1309) in the future. Is it real/doable to do like that?
The text was updated successfully, but these errors were encountered: