Logs from one Test class are displayed in other class's Standard output section in Gradle Test reports

泄露秘密 提交于 2021-02-08 08:53:41

问题


I am using TestNG (with gradle) for parallel test execution.

Gradle Task for executing my tests :-

task executeTests(type: Test) {
   useTestNG{
       options ->         
           options.parallel = 'classes'                 
           options.threadCount = 2
   }
}

I have some logging in tests. In Gradle reports logs of one test class are being printed in standard output section of some other test class when we execute tests in parallel.

To debug, I created 3 classes with one test each and printed Thread.currentThread().getId() with logs. In Gradle reports, last executed Test class's standard output section has logs with different thread ID's(these are from a different class).

Am I doing something wrong? How to get logging correct (I should be able to see the complete logging of a test class in its standard output section). Thanks in Advance.


回答1:


Gradle's test reporting has been implemented with Gradle's own parallel execution in mind, which is always single-thread-per-JVM (but possibly multi-JVM). Unless you need TestNG's notion of dependencies between tests, you will be better off using Gradle's parallel execution (e.g. executeTests.maxParallelForks = 2), which doesn't have this problem. Also, you could raise an issue for the original problem at http://forums.gradle.org.



来源:https://stackoverflow.com/questions/25002338/logs-from-one-test-class-are-displayed-in-other-classs-standard-output-section

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!