简体   繁体   English

testng在一个线程中运行所有测试类

[英]testng run all test classes in one thread

I have a project with tests, which runs using TestNG and maven. 我有一个带有测试的项目,该项目使用TestNG和maven运行。 TestNG runs test classes in several threads, what is not acceptable to me, I want to run all test classes in one thread. TestNG在多个线程中运行测试类,这是我不可接受的,我想在一个线程中运行所有测试类。 I know that it is possible to run all test methods inside of the specified test class in one thread, but how to run all test methods in all test classes in one thread? 我知道可以在一个线程中运行指定测试类中的所有测试方法,但是如何在一个线程中运行所有测试类中的所有测试方法呢? Is there any simple way to do it without depending each test class to previous? 有什么简单的方法可以做到,而不必将每个测试类都依赖于以前的测试类?

I've tried to configure maven surefire plugin like that, but it does'n work. 我已经尝试过像这样配置Maven surefire插件,但是它不起作用。

<configuration>
  <threadCount>1</threadCount>
</configuration>

I may be wrong in understanding your situation. 我在理解您的情况方面可能是错误的。 Ideally if different tests you have can't be run in parallel then you certainly have issues with the way tests are written. 理想情况下,如果您不能并行运行不同的测试,那么您肯定会在编写测试方式方面遇到问题。 Any test should not be dependent on any other test ideally and they should be capable of being run in parallel. 理想情况下,任何测试都不应该依赖于任何其他测试,并且它们应该能够并行运行。 If they can't be run in parallel then probably you will like to refactor your tests so that no test is dependent on any other test. 如果它们不能并行运行,那么您可能希望重构测试,以使任何测试都不依赖于任何其他测试。

默认情况下,TestNG不会并行运行,您必须在某个地方启用了并行模式,可能是在testng.xml的<suite>标记中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM