gpt4 book ai didi

java - 添加测试用例的方法

转载 作者:行者123 更新时间:2023-11-28 21:34:22 24 4
gpt4 key购买 nike

我正在以编程方式运行测试用例,例如,

    TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng=new TestNG();
testng.setTestClasses(new Class[] { UserGroupTest.class });
testng.addListener(tla);
testng.run();

我在 UserGroupTest.class 中保留了 8 个测试用例

是否可以通过 testCase 添加测试用例而不是添加整个类文件?因为我想在条件基础上运行测试用例。怎么做达?

最佳答案

如果您只想运行这些类中的某些方法,您有几个选择:

  • 将这些方法放在一个组中并调用 testng.setGroups(..)。
  • 创建一个模拟以下 XML 的 testng.xml(内存中可能是最简单的,因为您使用的是 API):

    <classes>
    <class name="test.methods.SampleMethod1">
    <methods>
    <include name="shouldRun1" />
    <include name="shouldRun2" />

关于java - 添加测试用例的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5460395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com