Search code examples
javaseleniumreportng

I want report in the order in which I have executed my test-cases. How can I configure it?


I'm running my automation suite with Selenium and Java with ReportNG as a reporting tool. When my test-runs are over I am getting the reportNG report in ascending order.

I want the report in the order in which they have been executed.

How can I do/configure that?

Thanks in advance.


Solution

  • Firstly you have to add ReportNG source files to your project. You can find them at https://github.com/dwdyer/reportng

    Then you need to edit TestResultComparator.class. Change compare method for this:

    Long a = Long.valueOf(result1.getStartMillis());
    Long b = Long.valueOf(result2.getStartMillis());
    return a.compareTo(b);
    

    This will order your Test Methods chronologically.

    After that edit TestClassComparator.class. Change compare method for this:

    Integer a = Integer.valueOf(class1.getXmlClass().getIndex());
    Integer b = Integer.valueOf(class2.getXmlClass().getIndex());
    
    return a.compareTo(b);
    

    It will order your Test Classes chronologically.