包括在测试的一种方法中多次的testng.xml执行步骤多次(Including one metho

2019-10-17 22:15发布

我想执行的一套测试方法多次作为测试的一部分。
我用TestNG指定我的测试。 我在的testng.xml文件中指定的测试是这样的:

<test>
        <classes>
            <class name="AddAppointment">
                <methods>
                    <include name="testLogin" />
                    <include name="addAppointment" />
                    <include name="checkApptForCurrentLocation" />
                    <include name="changeLocation" />
                    <include name="addAppointment" />
                    <include name="checkApptForCurrentLocation" />
                </methods>
            </class>
        </classes>
    </test>

执行此测试后,我看到重复的方法并没有得到执行。 它仅执行至“changeLocation'.Could任何人提出任何其他的解决办法或原因,这是不工作的考验吗?

请注意,我不想多次使用不同的数据集执行的方法。 因此,使用的dataProvider如我在网上找到绝不会帮我几个帖子建议。 因为我遵循严格的顺序
提前致谢!

Answer 1:

TestNG的是不是一种编程语言,并把它当作这样只会导致心碎。 addAppointmentchangeLocation是一种编程语言的动词,而不是测试。

它看起来像你有3个试验:试验进行登录,在一个特定的数据组合(默认或启动)的位置,并在另一位置的某个数据组合测试的测试。 你粘上这些测试使用共同的依赖,而不是使用方法测序/包括建筑。

具体而言,我建议你设置testLogin是使用一个名称,如组中startup ,并第一次取得实质性测试有一组依赖性startup 。 第二测试大量具有在所述第一实质测试的方法的依赖性。



文章来源: Including one method multiple times in a test in testng.xml to execute steps multiple times