GithubHelp home page GithubHelp logo

reportng's Introduction

ReportNG

ReportNG is a simple HTML reporting plug-in for the TestNG unit-testing framework. It is intended as a replacement for the default TestNG HTML report.

GitHub Release Date GitHub tag (latest by date) Maven Central Build

Sample report / Releases / Wiki / Maven Repository

Based on ReportNG v1.1.4 this is a ReportNG with :

  • new HTML layout
  • new semantics for Known and Fixed issues
  • summary report for Regression and New Features tests
  • graphs of Test Execution
  • and various fixes

Supported System Properties

  • org.uncommons.reportng.escape-output : Used to turn off escaping for log output in the reports (not recommended). The default is for output to be escaped, since this prevents characters such as '<' and '&' from causing mark-up problems. If escaping is turned off, then log text is included as raw HTML/XML, which allows for the insertion of hyperlinks and other nasty hacks.
  • org.uncommons.reportng.title : Used to over-ride the report title.
  • org.uncommons.reportng.show-passed-configuration-methods : Set to "true" or "false" to specify whether the pass Configuration methods (@BeforeClass,@AfterClass etc.) should be included in test output. Failures are reported by default always.
  • org.uncommons.reportng.knownDefectsMode : Set to "true" to specify if failed tests with @KnownDefect are marked as Known and pass tests with @KnownDefect are marked as Fixed. Otherwise if "false" then failed tests with @KnownDefect are marked as normally failed.
  • org.uncommons.reportng.logOutputReport : Set to "true" or "false" to specify if a summary of log output is generated and linked in test report.
  • org.uncommons.reportng.locale Over-rides the default locale for localised messages in generated reports. If not specified, the JVM default locale is used. If there are no translations available for the selected locale the default English messages are used instead. This property should be set to an ISO language code (e.g. "en" or "fr") or to an ISO language code and an ISO country code separated by an underscore (e.g. "en_US" or "fr_CA").
  • org.uncommons.reportng.skip.execution : Set to "true" whenever you need to skip the rest testNG execution.See for more Wiki/Tips
  • org.uncommons.reportng.show-suite-configuration-methods : Set to "true" to display @Before & @After suite methods into overview page. Otherwise, if false then suite configuration methods are displayed by default in the first/last test. Default value is false
  • org.uncommons.reportng.show-regression-column : Set to "true"/"false" in order to show/hide accordingly the column Regression into Overview page. The default value is false

How to use ReportNG

To use the reporting plug-in, set the listeners attribute of the testng element. The class names for the ReportNG reporters are:

org.uncommons.reportng.HTMLReporter
org.uncommons.reportng.JUnitXMLReporter

You may also want to disable the default TestNG reporters by setting the useDefaultListeners attribute to "false".

Usage of @KnownDefect

import org.uncommons.reportng.annotations.KnownDefect;

@KnownDefect(description="Jira Ticket XXXX")
@Test(description = "Test1")
public void test1() throws Exception {
    /*Test Code that eventually will produce an Exception*/
     new Exception("Assert Error");
}

By enabling the "org.uncommons.reportng.knownDefectsMode" the above test will be marked as Known Defect. If test doesn't throw any Exception then the test will be marked as Fixed.

Usage of @Feature

import org.uncommons.reportng.annotations.Feature;

@Feature(description = "This is a Feature")
public class Test1 {
	@Test(description = "Test1")
	public void test1() throws Exception {
	/*Test Code*/
}
}

Test Classes with @Feature will be reported as Regression tests.

Usage of @NewFeature

import org.uncommons.reportng.annotations.NewFeature;
 
@NewFeature(description = "This is a new Feature")
public class Test1 {
	
@Test(description = "Test1")
public void test1() throws Exception {
    	/*Test Code*/
}
}

Test Classes with @NewFeature will be reported as new Features tests.

Usage of Skip Execution

At any point but it’s advisable to be the first case in suite xml, you can set this system variable to "true" and skip the rest of test execution, for example :

@Test(description = "In case of a failure Skip Execution")
public void testLoginPage() throws Exception {
try{
	loginToMyTestEnv();
}catch(Exception ex){
	System.setProperty("org.uncommons.reportng.skip.execution","true");
	throw ex;
}
}

By enabling this system property all of the rest testNG tests will be skipped and the generated report will have on overview page the root cause of the failure providing the message "Skip Execution due to Skip Execution Mode". Alternative you can use this system property in your TestListener and Skip test execution on the first failure. This will work as Fail Fast Mode. See Wiki for example.

Usage of embedded listeners

ReportNG has available to use some extra testNG listeners. Currently a "Fail Fast", a "Test Retry" & the "Test Time Out" Listener. To enable them you need to set the listeners attributes of the testng element. For fail fast mode :

org.uncommons.reportng.listeners.FailFastListener

For timeout and retry test :

org.uncommons.reportng.listeners.Retry
org.uncommons.reportng.listeners.IAnnotationTransformerListener

Both required and both can be parameterized as concerns the timeout and the max retries by system properties, accordingly :

System.setProperty("org.uncommons.reportng.timeout", "6000");
System.setProperty("org.uncommons.reportng.maxRetryCount", "2");

Timeout is in milliseconds , in case of 0 the listener is not invoked.

MaxRetryCount is the maximum number of retries until test is pass, in case of 0 again the listener is not invoked.

Mvn dependency :

  <dependency>
   <groupId>com.github.sdrss</groupId>
   <artifactId>reportng</artifactId>
   <version>2.7.0</version>
  </dependency>

reportng's People

Contributors

dependabot[bot] avatar sdrss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

reportng's Issues

ReportNG report tells me that 0 tests have been run, when actually 6 have been run

ReportNG generates the report for me, but it says that 0 tests have been run when actually 6 have been run

My configuration is:

Pom


4.0.0

<groupId>org.example</groupId>
<artifactId>Automatizacion_CS</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFiles}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.17</version>
    </dependency>
    <!--JDBC SQL SERVER DEPENDENCIA   -->
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.1.0.jre8</version>
    </dependency>

    <!--Administrador de Browser Drivers-->
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>5.0.3</version>
        <scope>test</scope>
    </dependency>
    <!--Reporte TestNG-->
    <dependency>
        <groupId>com.github.sdrss</groupId>
        <artifactId>reportng</artifactId>
        <version>2.6.5</version>
    </dependency>
    <!--
    <dependency>
        <groupId>org.uncommons</groupId>
        <artifactId>reportng</artifactId>
        <version>1.1.4</version>
    </dependency>-->

</dependencies>

xml:

<listeners>
    <listener class-name="org.uncommons.reportng.HTMLReporter" />
    <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>


<test name="CUA04">
    <parameter name="nameTest" value="CUA04"></parameter>
    <parameter name="url" value="http://10.253.15.199/sib/transaction/LOGON.asp"/>

    <parameter name="userName" value="JOBRAN"/>
    <parameter name="userPassword" value="JOBRAN16"/>

    <parameter name="CANAL_Y_PRUEBA" value="45"/>

    <parameter name="canal" value="PortalFinanciero"/>
    <parameter name="webDriver" value="EG"/>

    <classes>
        <class name="myTests.PortalFinanciero.CUA04">
        </class>
    </classes>
</test>

Java class:

package myTests.PortalFinanciero;

import core.Base;
import core.FileExcelProvider;
import core.TestListener;
import core.Utilities;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.ITestContext;
import org.testng.Reporter;
import org.testng.annotations.*;

import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import static core.Utilities.*;

@listeners(TestListener.class)
public class CUA04 extends Base {

private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
private JavascriptExecutor js;

@DataProvider(parallel=true)
public Object[][] getProvider(){
    String[] archivos = {
            "C:/Reportes/CUA04.xlsx"
    };

    int[][] matrizDeConversion = {
            {1}
    };

    FileExcelProvider file = new FileExcelProvider(archivos,matrizDeConversion);
    Object[][] data = file.getData();
    return data;
}

//Elimina las imagenes de la carpeta C:/Reportes
@BeforeClass
public void BeforeClass() throws NoSuchFieldException, IllegalAccessException {
    /*Utilities EliminarPorExtension = new Utilities();
    EliminarPorExtension.EliminarPorExtension();
    System.out.println("Se Elimino correctamente las imagenes en la carpeta reportes");*/
}


@Test(dataProvider = "getProvider")
public void CUA04(Object[] object, ITestContext context) throws  NoSuchFieldException, IllegalAccessException {
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    ArrayList<String> datos = convertObjectToArrayString(object);

    ///Escritura del Titulo de la Prueba
    Utilities Doc = new Utilities();
    if(Utilities.getCont()==0){
        writeTitleDoc("Prueba automatizada transacción - CUA04");
    }
    Reporter.log("Se escribe un msj en el reporte");
    writeLog("*");
    writeLog("*");
    writeLog("Cargando las Preferencias del Navegador");
    //Espera hasta que se haya cargado el Portal

    /*Espera al cargar preferencias, esto es propio del portal financieros*/
    if(Utilities.getCont()<=1){
        System.out.println("Realiza la espera de que cargue la pagina la primera vez");
        WebElement foo = new WebDriverWait(driver, 15).until(driver -> driver.findElement(By.id("clsTb4_Cliente360")));
        threadslepp(1500);
    }

    try {
        /*Presiona F9 para ingresar a la TRX*/

        writeLog("Inicia la Iteracion");
        driver.switchTo().defaultContent();
        keyPress(KeyEvent.VK_F9);
        //threadslepp(500);
        Doc.writeSubTitleDoc("Caso - "+datos.get(0));
        Doc.takeScreenShotJB(driver, "1. Muestra dialogo para ingresar la transaccion a realizar.");
        writeLog("Busca el componente para poder colocar la transaccion a buscar");
        String transaccion = datos.get(1);
        System.out.println("Transaccion que se procesara: " + transaccion);
        //sendKeystoElement(driver,"TRXDESC", transaccion,"");
        sendKeystoElement(driver,"//*[@id=\"TRXDESC\"]", transaccion,"2. Ingresa el codigo de la transaccion que queremnos ejecutar: "+transaccion);


        /*Presiona Enter para ir a la transaccion*/
        writeLog("Presionara Enter");
        keyPress(KeyEvent.VK_ENTER);
        writeLog("Ingresa a la Transaccion");


        /*Cambia de Frame*///DetailMain
        threadslepp(1000);
        System.out.println("Cambia de Frame");
        driver.switchTo().frame("DetailMain");

        //Ingresar Agencia
        writeLog("Ingresa la Agencia: " + datos.get(2));
        sendKeystoElement(driver,"input[id='SCO_AGENCIA']",  datos.get(2), "3. Ingresa el código de la Agencia: "+datos.get(2));

        //Ingresa la Jornada
        writeLog("Ingresa la Jornada: " + datos.get(3));
        selectOption(driver, "SCO_TURNO", datos.get(3),"" );

        //Ingresa la Fehca
        writeLog("Ingresa la Fecha: " + datos.get(4));
        sendKeystoElement(driver,"input[id='AFE_FECHA']",  datos.get(4), "5. Ingresa la fecha de la cual queremos generar el reporte: "+datos.get(4));

        //Ingresa la Moneda
        writeLog("Ingresa la Moneda: " + datos.get(5));
        sendKeystoElement(driver, "input[id='ACO_MONED']", datos.get(5), "6. Ingresa el código de la Moneda: "+datos.get(5));

        //Ingresa el Proceso a Ejecutar
        selectOption(driver, "SCO_TIPO", datos.get(6), "7. Selecciona el proceso que queremos ejecutar: ");

        //Da click en el boton para generar el reporte
        Doc.takeScreenShotJB(driver, "8. Presiona el boton Generar para generar el reporte.");
        clickElementIfExist(driver, "//input[@value='Generar']");
        threadslepp(500);

        driver.switchTo().defaultContent();

        //Si sucede un error lo Captura
        driver.switchTo().frame("DetailMain");

        capturarError(driver, "description", null, "9. Se a capturado el siguiente error: ");

        //Retorna a la ventana Principal
        driver.switchTo().defaultContent();


    }catch(Exception e){
        //VENTANA EMERGENTE -- Error
        try {
            capturarError(driver, "description", "BOTON", "9. Se a capturado el siguiente error: ");
            System.out.println("Primer Catch: " +e.getMessage());

        }catch (Exception ex){
            try {
                capturarError(driver, "MESSAGE", null, "9. Se a capturado el siguiente error: ");
                System.out.println("Segundo Catch: "+ex.getMessage());

            }catch (Exception exx){
                System.out.println("Error No mapeado");
                System.out.println("Tercer Catch: "+exx.getMessage());
            }
        }
    }
}

//Despues de finalizar la prueba automatizada, se genera un documento con todas las pantallas realizadas
@AfterClass
public void AfterClass(){
    //Obtengo el usuario de Windows
    String usuario = System.getProperty("user.name");
    writeLog("Se generó correctamente Evidencia de Pruebas- .docx");
    //Cierra el Navegador y el Driver
    //driver.quit();

}

}

Mensaje en el reporte generado:
image

Failed generating JUnit XML report

Hello, I'm using sdrss/reportNG(2.6.2) and jacoco(0.8.5) at the same time, but something wrong occurred when generating report files, the output logs:

2021-08-03 12:36:24.249  INFO 3642 --- [           main] org.uncommons.reportng.HTMLReporter      : ****************************************

2021-08-03 12:36:24.249  INFO 3642 --- [           main] org.uncommons.reportng.HTMLReporter      : Generate reportNG report

2021-08-03 12:36:24.249  INFO 3642 --- [           main] org.uncommons.reportng.HTMLReporter      : Path : /Users/yclin/codes/java/szaud-platform-backend/target/surefire-reports/html

2021-08-03 12:36:24.401  INFO 3642 --- [           main] org.uncommons.reportng.HTMLReporter      : ****************************************
[TestNG] Reporter [JUnitXMLReporter passed=0 failed=0 skipped=0] failed
org.uncommons.reportng.ReportNGException: Failed generating JUnit XML report.
        at org.uncommons.reportng.JUnitXMLReporter.generateReport(JUnitXMLReporter.java:70)
        at org.testng.TestNG.generateReports(TestNG.java:1097)
        at org.testng.TestNG.run(TestNG.java:1022)
        at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
        at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
        at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.io.FileNotFoundException: /Users/yclin/codes/java/szaud-platform-backend/target/surefire-reports/xml/net.engyne.szaudplatformbackend.controller.AuthControllerTest_results.xml (No such file or directory)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
        at java.io.FileWriter.<init>(FileWriter.java:90)
        at org.uncommons.reportng.AbstractReporter.generateFile(AbstractReporter.java:85)
        at org.uncommons.reportng.JUnitXMLReporter.generateReport(JUnitXMLReporter.java:68)
        ... 9 more
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.146 s - in TestSuite

My pom.xml:

        <dependency>
            <groupId>com.github.sdrss</groupId>
            <artifactId>reportng</artifactId>
            <version>2.6.2</version>
        </dependency>

        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.5</version>
        </dependency>

My testng.xml:

<suite name="All Test Suite">
    <test verbose="2" preserve-order="true" name="AuthTests">
        <classes>
            <class name="net.engyne.szaudplatformbackend.controller.AuthControllerTest"/>
        </classes>
    </test>
    <listeners>
        <listener class-name="org.uncommons.reportng.HTMLReporter"/>
        <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
    </listeners>
</suite>

Any helpful suggestions would be appreciated, thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.