Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何并行运行@Before注释?_Java_Parallel Processing_Testng - Fatal编程技术网

Java 如何并行运行@Before注释?

Java 如何并行运行@Before注释?,java,parallel-processing,testng,Java,Parallel Processing,Testng,我有几个测试类,每个类都有@BeforeClass。 我添加了在xml中并行运行的选项,但是BeforeClass方法似乎是按顺序运行的 如何配置它们,使它们同时运行 <suite name = "TestAllPersonTypes"> <test name = "TestEmployer" parallel="methods" thread-count="5"> <classes> <class na

我有几个测试类,每个类都有
@BeforeClass
。 我添加了在xml中并行运行的选项,但是BeforeClass方法似乎是按顺序运行的

如何配置它们,使它们同时运行

<suite name = "TestAllPersonTypes">

    <test name = "TestEmployer" parallel="methods" thread-count="5">
        <classes>
            <class name = "com.mobile.tests.empr.ValidateEmployerBusinessA"/>
        </classes>
    </test>

    <test name = "TestEmployee" parallel="methods" thread-count="5">
        <classes>
            <class name = "com.mobile.tests.empe.ValidateEmployeeBusinessA"/>
        </classes>
    </test>

    <test name = "TestAgent" parallel="methods" thread-count="5">
        <classes>
            <class name = "com.mobile.tests.agnt.ValidateAgentBusinessA"/>
        </classes>
    </test>

</suite>

问题在于您正在为每个测试指定并行性。 您基本上是告诉每个测试并行运行其方法

您需要做的是告诉您的整个套件并行运行您的测试。这样,每个类的每个方法(不仅仅是@Before注释)都将并行运行

您可以通过从测试中删除并行化并将以下内容添加到套件中来完成此操作:

<test name = "TestEmployer">
    <classes>
        <class name = "com.mobile.tests.empr.ValidateEmployerBusinessA"/>
    </classes>
</test>

<test name = "TestEmployee">
    <classes>
        <class name = "com.mobile.tests.empe.ValidateEmployeeBusinessA"/>
    </classes>
</test>

<test name = "TestAgent">
    <classes>
        <class name = "com.mobile.tests.agnt.ValidateAgentBusinessA"/>
    </classes>
</test>



您可以在

中了解更多这方面的信息,您能告诉我们您现在在做什么以便我们可以看到吗?您的xml和类的示例。我添加了我的xml。明天我可以添加我的测试,因为我必须更改我的项目的信息,而且它们有很多类。但是它们基本上都是简单的类,有几个测试,每个类中都有一个beforeclass方法?就像我在上面印的一样。在那里。这就是你需要的吗?