I have a scenario where @Factory annotation is used to run multiple instances/threads of the same test.
Simply put, you have a test Test001, and you want to run it in 2 parallel threads, each thread having its own set of params. So we have a method which will return Object[] having 2 instances of the test with different input. We are running this in parallel programatically (creating a xml suite and using testng.run()). This works fine for normal tests. However, this gets complicated in case of DataDriven tests.
@Factory
@Parameters({"noOfInstances"})
public Object[] createInstances(int noOfInstances) {
...
}
We have a Data driven framework where we create test objects from the data file again using @Factory.
@Factory
@Parameters({ "dataFile" })
public Object[] getTests(@Optional("") String dataFile) {
...
}
What I see is when I try to run multiple instances of a DD test, I find unnecessary repetition and failures.
Suppose I run 1 instance of DD test TestDD1, and data in file has input data for tests 1, 2
Expectation: Run
TestDD1-1
TestDD1-2
Actual: Ran
TestDD1
TestDD1-1
TestDD1-2
And TestDD1 fails while the other 2 pass.
Similarly, if I run 2 instances/threads of DD test TestDD1,
Expectation: Run (|| denotes in parallel)
TestDD1-1 || TestDD1-1
TestDD1-2 || TestDD1-2
Actual: Ran
TestDD1 || TestDD1
TestDD1-1 || TestDD1-1
TestDD1-2 II TestDD1-2
What changes can I make to achieve what I need? Is it possible to remove one of the @Factory annotations and modify code in the manner to achieve my requirement? Or, can I intercept the test objects returned by Factory and exclude ones I don't need? Is there any other TestNG functionality that I can use?
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/x_1OZJiQZ24J.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.