问题
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