如何使用 Springboot 命令行参数运行 selenium testng 套件
我有一个基于 Spring boot 的 Java selenium 项目,它使用 testng xml 文件运行测试套件。 我想使用 Spring boot 命令行参数为用户提供运行哪个套件的选项。 用户将列出所有可用的测试套件,用户可以选择。 由于某些原因,我正在将应用程序构建为 war 而不是 jar。 当我们运行战争时,使用 jar -xvf myapplication-local.war, 它应该打印以下内容,
从以下测试套件列表中选择要运行的测试套件,
- 登录
- Checkcustomerdetails
- Checkcustomeraddress
测试套件映射如下:
- Login - login.xml
- Checkcustomerdetails - checkcustomerdetails.xml
- Checkcustomeraddress - checkcustomeraddress.xml
如果用户输入 1 和单击“ENTER”,应运行 login.xml 如果用户输入 2 并单击“ENTER”,则应运行 checkcustomerdetails.xml
以下命令非常冗长,我们可以让它做得更好一点吗?
--java -cp "./WEB-INF/lib/*;./WEB-INF/classes;./myapplication-local.war" org.testng.TestNG "./WEB-INF/classes/testscripts/login. xml”
@SpringBootApplication
public class MyApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
public void run(String... args) throws Exception {
}
}
I have a Spring boot based Java selenium project which runs the test suites by using testng xml file.
I want to use Spring boot command line arguments to give option for the user to run which suite to run.
User will be listed all the test suites available, which user can select.
I am building the application as war instead of jar for some reasons.
when we run the war, using jar -xvf myapplication-local.war,
it should print the following,
Chose the Test Suite to run from the following list of Test suites,
- Login
- Checkcustomerdetails
- Checkcustomeraddress
Test Suites are mapped as below:
- Login - login.xml
- Checkcustomerdetails - checkcustomerdetails.xml
- Checkcustomeraddress - checkcustomeraddress.xml
if user types 1 and clicks 'ENTER', should run login.xml
if user types 2 and clicks 'ENTER', should run checkcustomerdetails.xml
The following command it is very lengthy, can we make it do a little better.
--java -cp "./WEB-INF/lib/*;./WEB-INF/classes;./myapplication-local.war" org.testng.TestNG "./WEB-INF/classes/testscripts/login.xml"
@SpringBootApplication
public class MyApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
public void run(String... args) throws Exception {
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论