按顺序和并行运行 TestNG 组 [英] Run TestNG groups both sequentially and in parallel
问题描述
好的,参考 TestNG doc 我可以运行测试顺序(默认在测试套件中)或并行使用
.
Ok, so referring to TestNG doc I can run tests either sequentially (by default in a test suite) or in parallel using <suite parallel="tests">
.
现在这是我的 TestNG 配置
Now here is my TestNG config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Complete test suite">
<listeners>
<listener class-name="com.uas.test.portlet.integration.util.WebDriverListener" />
<listener class-name="org.uncommons.reportng.HTMLReporter" />
</listeners>
<test name="Parallel tests" parallel="methods" thread-count="4">
<groups>
<run>
<exclude name="sequential-test"></exclude>
</run>
</groups>
<packages>
<package name="com.uas.test.portlet.integration.main" />
<package name="com.uas.test.portlet.integration.main.categorymanager" />
<package name="com.uas.test.portlet.integration.main.admin" />
</packages>
</test>
<test name="Sequential tests" parallel="false" >
<groups>
<run>
<include name="sequential-test"></include>
</run>
</groups>
<packages>
<package name="com.uas.test.portlet.integration.main" />
<package name="com.uas.test.portlet.integration.main.categorymanager" />
<package name="com.uas.test.portlet.integration.main.admin" />
</packages>
</test>
</suite>
如您所见,我有两种类型的测试:可以并行运行的测试和其他应按顺序运行的测试.我的套件中没有 parallel=tests
属性,所以
标签顺序运行,这样我的第一个并行测试组是先运行,然后是顺序运行.
As you can see, I have 2 types of tests : tests which can be run in parallel and others that should be run in sequential. No parallel=tests
attribute in my suite so <test>
tags are run sequentially, in such a manner that my first parallel test group is run first and then the sequential ones.
这是完美的,但我想比这更进一步,我的顺序测试有 2 个子组,每个子组都可以彼此并行运行,但都在主要并行测试之后......不幸的是我没能做到......所以总结一下我想要的:
That is perfect, but I would like to go a bit further than this and have 2 subgroups of my sequential tests, each of which could be run in parallel with each other, but both after the main parallel tests... unfortunately I haven't been able to do that... So to summarize what I want :
1. RUN Parallel tests main group
THEN
2. RUN Sequential tests main group
--> Sequential subgroup A RUNS IN PARALLEL with Sequential subgroup B (test 1 from subgroup A could run in parallel with test 3 from subgroup B, they are independant)
--> Each test within subgroup A should run sequentially
--> Each test within subgroup B should run sequentially
知道如何使用 TestNG 配置文件做到这一点吗?(我想避免使用 Ant 等).
Any idea on how to do that with TestNG config file ? (I would like to avoid using Ant or such).
推荐答案
两个独立的套件可能会有所帮助.它们将依次执行.只需根据您的需要将您的测试放入其中.
Two separate suites may help. They will be executed sequentially. Just put your tests inside of them depending on what you need.
<suite-files>
<suite-file path="./suite1.xml" />
<suite-file path="./suite2.xml" />
</suite-files>
这篇关于按顺序和并行运行 TestNG 组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!