Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悶: ClassCastException when using TestNG 7.9.0 with use-global-thread-pool="true" #1013

Open
1 task done
Pavlo-Tiutiunnyk opened this issue Mar 1, 2024 · 0 comments
Labels
triage type:bug Something isn't working

Comments

@Pavlo-Tiutiunnyk
Copy link

What happened?

TestNg has recently released new version with a feature that allows using shared thread pool for all data driven and non data driven tests
When using it with allure testng, the tests throws ClassCastException

Please see the examples attached

build.gradle

buildscript {
    ext {
        allureVersion = '2.25.0'
        aspectjVersion = '1.9.21.1'
        testngVersion = '7.9.0'
    }
}

plugins {
    id 'java'
    id 'idea'
    id "io.freefair.aspectj.post-compile-weaving" version "8.6"
    id 'io.qameta.allure' version '2.11.2'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    implementation("org.testng:testng:$testngVersion")
    implementation platform("io.qameta.allure:allure-bom:$allureVersion")
    implementation("io.qameta.allure:allure-testng:$allureVersion")
    implementation("org.aspectj:aspectjweaver:$aspectjVersion")
    implementation("org.aspectj:aspectjrt:$aspectjVersion")
}

task runOneTest(type: Test) {
    useTestNG() {
        suites "src/test/resources/test_suites/allure_testng_test.xml"
    }
}

test class

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.util.concurrent.ThreadLocalRandom;

public class AllureTestngTest {
    
    private static final int dataSize = 25;

    @Test(dataProvider = "dp")
    public void parallelDataDrivenTest1(int i) {

    }
    @Test(dataProvider = "dp")
    public void parallelDataDrivenTest2(int i) {

    }
    
    @DataProvider(name = "dp", parallel = true)
    public Object[][] getData() {
        Object[][] data = new Object[dataSize][1];
        for (int i = 0; i < dataSize; i++) {
            data[i][0] = ThreadLocalRandom.current().nextInt();
        }
        return data;
    }
}

testng xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.1.dtd" >

<suite name="Example suite" parallel="methods" use-global-thread-pool="true" thread-count="4">
    <test name="One Test">
        <classes>
            <class name="AllureTestngTest"/>
        </classes>
    </test>
</suite>

stack trace

class java.util.concurrent.CompletableFuture$AsyncSupply cannot be cast to class java.lang.Comparable (java.util.concurrent.CompletableFuture$AsyncSupply and java.lang.Comparable are in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class java.util.concurrent.CompletableFuture$AsyncSupply cannot be cast to class java.lang.Comparable (java.util.concurrent.CompletableFuture$AsyncSupply and java.lang.Comparable are in module java.base of loader 'bootstrap')
	at java.base/java.util.concurrent.PriorityBlockingQueue.siftUpComparable(PriorityBlockingQueue.java:349)
	at java.base/java.util.concurrent.PriorityBlockingQueue.offer(PriorityBlockingQueue.java:475)
	at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357)
	at java.base/java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1782)
	at java.base/java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:2005)
	at org.testng.internal.invokers.MethodRunner.runInParallel(MethodRunner.java:143)
	at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:950)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:201)
	at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.testng.internal.thread.graph.TestNGFutureTask.run(TestNGFutureTask.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

What Allure Integration are you using?

allure-testng

What version of Allure Integration you are using?

2.25.0

What version of Allure Report you are using?

2.25.0

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Pavlo-Tiutiunnyk Pavlo-Tiutiunnyk added triage type:bug Something isn't working labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant