Search code examples
javac#automated-teststestngextentreports

How to change the css of testng reports?


Is there a way to change the css/customize the html of TestNG Reports (not programmatically)?

I am using TestNG default reports.


Solution

  • This needs to be done programmatically. Create a sub-class of EmailableReporter2 class. Override the writeStylesheet method as follows

    protected void writeStylesheet() {
        writer.print("<link rel=\"stylesheet" href=\"/path/to/your/css/file.css\">");
    }
    

    or if u want to use internal css

    protected void writeStylesheet() {
        writer.print("<style type=\"text/css\">");
        writer.print("your css");
        writer.println("</style>");
    }
    

    Use this sub-class as your TestNG listener class