是否可以存档TestNG的报告?

时间:2014-10-30 09:41:56

标签: selenium-webdriver report automated-tests testng

如何在Selenium 2(Webdriver)中存档测试的结果(报告),以便能够返回它们?每个性能套件都会覆盖以前的报告,因为它可以被阻止?我使用简单的HTML报告。

1 个答案:

答案 0 :(得分:1)

//例如,您希望测试此类并希望为每个执行创建新的输出文件夹

公共类TestClass {

@Test
public void testME(){
    System.out.println("Success");
}

}

//Then create  new class which will be the start point of your execution, and run it from here


public class MainClass {

    //This code will be your start point of execution
    @Test
    public void testCode(){
        Random randomNo = new Random();
        TestListenerAdapter listener = new TestListenerAdapter();
        TestNG testng = new TestNG();

        //Here you are changing Output directory and archive it for further 
        //use, OUTPUT FOLDER WILL BE ADDED BY APPPENDING RANDOM NUMBER ON IT
        testng.setOutputDirectory("test-output"+randomNo.nextInt());

        //ADD ALL TEST CLASSES WHERE YOUR TESTNG CODE IS PRESENT WITH @Test 
        testng.setTestClasses(new Class[]{TestClass.class});
        testng.addListener(listener);
        testng.run();
    }

}