Skip to content

How to print exceptions on console? I am using TestNG and Maven

I want to see the exceptions on console. I am using TestNG with Maven as a build tool. I have defined my testng.xml in the Maven surefire plugin.



you should use above reporter , but the constructor expects a string so you cannot initialize it using testng.xml ( if any one knows how to pass string argument to listener in testng.xml please do add it here )

So the work around is to add the listener through script and initiate testng through a java entry file.

public static void main(String[] args) {

        TestNG testng = new TestNG();

        // Create a list of String
        List<String> suitefiles = new ArrayList<String>();

        // Add xml file which you have to execute

        // now set xml file for execution
        testng.addListener(new VerboseReporter("[TestNG] "));

        // finally execute the runner using run method;



enter image description here


As this reporter constructor expects a string you should not provide it in your testng.xml you will get initialization error

6 People found this is helpful