简体   繁体   English

如何在不同的URL上使用Selenium和JUnit 5运行整个测试套件

[英]How to run an entire test suite with Selenium & JUnit 5 on different URLs

I have a test class that currently uses parameterized tests to run each test on different URLs. 我有一个测试类,当前使用参数化测试在不同的URL上运行每个测试。 However I want the output to be in the form 但是我希望输出形式为

Url 网址

  • Failed Test 1 测试失败1
  • Failed Test 2 测试失败2

instead of 代替

Test 测试

  • Failed URL 1 URL 1失败
  • Failed URL 2 URL 2失败

I can accomplish this by having a seperate class for each URL but there are over 300 URLs so that's not really an option. 我可以通过为每个URL设置单独的类来实现此目的,但是有300多个URL,所以这不是一个真正的选择。 The classes would be the same except for paremters though so: 这些类是相同的,除了paremters一样:

  1. Is there a way to do this in JUnit (essentially I want to parameterize the whole class) if not: 如果没有,是否可以在JUnit中执行此操作(本质上是想对整个类进行参数化):
  2. Would log4j be able to accomplish this if not: 如果没有,log4j能够做到这一点:
  3. Is there a way to make the classes at runtime automatically if not: 如果没有,是否可以在运行时自动创建类:
  4. What testing framework can accomplish this, I am open to any software that can do this 什么测试框架可以完成此任务,我欢迎任何可以执行此操作的软件

My problem is similar to this: Running same tests against a large number of websites 我的问题与此类似: 对大量网站运行相同的测试

Used the below parameterized test class and got the result. 使用下面的参数化测试类并获得结果。 All tests for a parameter are executed before next parameter is used. 在使用下一个参数之前,将对参数进行所有测试。

@RunWith(Parameterized.class)
public class ParamTest {

    @Parameters
    public static Object[] data() {
        return new Object[] { "google", "yahoo", "facebook" };
    }

    @Parameter
    public String url;

    @Test()
    public void test1() {
        System.out.println("Test 1 - "+url);
    }

    @Test()
    public void test2() {
        System.out.println("Test 2 - "+url);
    }
}

Test 1 - google
Test 2 - google
Test 1 - yahoo
Test 2 - yahoo
Test 1 - facebook
Test 2 - facebook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM