我正在尝试 Cedric Beust 在其他线程中建议的以下内容。
您可以自己将其作为预测试任务执行:实现一个代码生成器,以 XML 形式获取信息,获取相应的 Java 源文件并生成一个 TestNG 源文件,其中所有注释都放置在正确的位置。然后在该文件上运行 TestNG。
我对代码生成一无所知。有人可以指导我正确的方向吗?一些简单的例子会很棒。
更新:这是我想要生成的模板。
public class <tobeReadFromConfigFile>
{
@Test(groups="to be read from config file")
public void <tobereadfromconfigfile>{
//to be read from config file(Name of function to call)
//to be read from config file(Name of function to call)
//to be read from config file(Name of function to call)
}
.
.
.
}
函数内部的代码只是函数调用,必须从配置文件中完全读取和复制。