Comments (10)
Reproduced this error, i'm working on this.
from testng.
found a fix, will be posting it soon :)
from testng.
Thanks for finding this issue and posting the workaround. I just spent an hour or two trying to figure out why my test methods in the same class were running in parallel. Adding an empty @Test
method resolves this issue. I tested TestNG 6.8 and 6.8.8 and both had this problem, so either the issue wasn't fixed or it has regressed.
from testng.
Any chance this could be fixed?
from testng.
This works as expected:
Here are my (little bit modified) classes:
package com.example;
public class A {
@org.testng.annotations.Test
public void someMethodA1() {
PrintThread.message("in A");
}
}
package com.example;
public class B extends A {
@org.testng.annotations.Test
public void someMethodB1 () {
PrintThread.message("in B");
}
}
package com.example;
public class C extends B {
//@org.testng.annotations.Test
public void veryImportant() {
PrintThread.message("in c");
}
}
package com.example;
public class PrintThread {
public static void message(String s) {
System.out.println("START["+Thread.currentThread().getId()+"]: " + s);
synchronized (s) {
try { s.wait(1000); }
catch (InterruptedException e) {}
}
System.out.println("END["+Thread.currentThread().getId()+"]: " + s);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Some Suite" >
<test name="Some tests" parallel="classes" thread-count="3">
<packages>
<package name="com.example"/>
</packages>
</test>
</suite>
The output when @test in C is commented:
START[11]: in A
START[12]: in A
START[13]: in A
END[12]: in A
END[11]: in A
END[13]: in A
START[12]: in B
START[11]: in B
END[12]: in B
END[11]: in B
So it is seen that:
- two tests were executed for class B in its own thread
- two tests were executed for class C in its own thread
- one test was executed for class A
All is as expected.
The output when @test in C is uncommented:
START[14]: in A
START[16]: in A
START[15]: in A
END[15]: in A
END[14]: in A
END[16]: in A
START[15]: in B
START[16]: in B
END[16]: in B
END[15]: in B
START[16]: in c
END[16]: in c
So it is seen that:
- three tests were executed for class C in its own thread (16)
- two tests were executed for class B in its own thread (15)
- one test was executed for class A (14)
All is as expected.
from testng.
@khospodarysko thanks for an example.
However it doesn't contain an abstract class.
I have two classes and a suite:
public abstract class A {
@Test
public void test1() {
message("test1");
}
@Test
public void test2() {
message("test1");
}
public static void message(String s) {
System.out.println("START["+Thread.currentThread().getId()+"]: " + s);
synchronized (s) {
try { s.wait(1000); }
catch (InterruptedException e) {}
}
System.out.println("END["+Thread.currentThread().getId()+"]: " + s);
}
}
public class B extends A {}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Some Suite" parallel="classes" thread-count="8">
<test name="Some tests" >
<classes>
<class name="B"/>
</classes>
</test>
</suite>
what i get is two test running in separate threads:
START[12]: test1
START[13]: test1
END[13]: test1
END[12]: test1
what i expect to get is two tests running in the same thread cause they belong to a same class.
from testng.
Hey, @sergejjkim
Your are right, I forgot about abstract.
So the one thing I did is I made classes A and B as abstract and get such output:
START[12]: in A
END[12]: in A
START[12]: in B
END[12]: in B
START[12]: in c
END[12]: in c
Is that what you are expecting?
from testng.
@khospodarysko
ok so I've made A and B abstract in your example with @test in C commented and got
START[13]: in B
START[12]: in A
END[12]: in A
END[13]: in B
which is basically not what I'd expect to see. Also it's more about having 2 classes with 2+ methods in the abstract one.
from testng.
@sergejjkim Got it!
Similar Eclipse-related issues that I've found are:
I'd say this case is rather edge-case. If one of subclasses has one @test method all is OK.
from testng.
Any update or idea to fix this issue? We use a lot of abstract class tests to override just some small part of them with sub classes to change a behavior. These subclasses have no test inside, but added an empty one made these tests ran in a single thread as expected.
from testng.
Related Issues (20)
- Test methods skipped after failed AfterMethod HOT 1
- assertEqualsDeep(Set, Set, String) fails when it shouldn't HOT 1
- MavenProject coming null inside ITestContext HOT 9
- While creating a custom code for html table in emailablereport.html, Multiple <br> tags are getting added HOT 4
- NPE when retrieving Retry analyzer if none is defined HOT 3
- Error while downloading DTD. HOT 1
- onStart (ITestListener) is executed one time before the first class in package HOT 3
- TestNG execution hangs with version 7.9 or higher, with large amount of test cases HOT 16
- TestNG 6.11 to 7.5.1, execution sort order is modified HOT 7
- RetryAnalyzer triggered before @AfterMethod HOT 6
- DataProvider with cacheDataForTestRetries = false Does Not Update Test Method Parameters on Retry in TestNG
- [meta] Refactor Suite XML Capabilities HOT 1
- Convert DTD into XSD format
- Utilize JAXB to generate a structured class hierarchy based on the XSD that was created in the previous step.
- Parse the suite files using JAXB, employing the generated class hierarchy to create instances of objects from the file content.
- Perform a thorough evaluation to determine if there are any potential conflicts or issues when integrating both XSD and DTD.
- Develop comprehensive documentation for end users. This documentation will serve as a helpful resource, guiding users in the process of replacing DTD with the new XSD schema.
- Selenium Issue org.testng.log4testng.Logger info HOT 2
- Subsequent skipped configurations do not set a throwable HOT 2
- @Test Method is Retried Endlessly When Parameters Are Modified Before Rerun HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testng.