testng自带的report样式不美观,可以使用testng的一个plugin reportng来生成报告,具体的做法如下


使用intellij idea创建一个maven项目,在项目的pom.xml文件中引入reportng的dependency,具体如下:


    4.0.0

    TestNGProj
    TestNGProj
    1.0-SNAPSHOT
    
        
            org.testng
            testng
            6.8.21
        
        
            org.uncommons
            reportng
            1.1.4
            test
            
                
                    org.testng
                    testng
                
            
        
        
            com.google.inject
            guice
            3.0
            test
        
    
    
        
            
                org.apache.maven.plugins
                maven-resources-plugin
                2.5
            
            
                org.apache.maven.plugins
                maven-surefire-plugin
                2.12
                
                    
                        src/main/java/testng.xml
测试生成的报告
运行项目中的testng.xml文件,执行成功后,生成的报告地址位于项目的此目录下:test-output/html/index.html
例如:file:///Users/Vicky/Documents/vicky/TestNGProj/test-output/html/index.html。
生成的报告样式: