Class AbstractReporter

  • All Implemented Interfaces:
    org.testng.IReporter, org.testng.ITestNGListener
    Direct Known Subclasses:
    HTMLReporter, JUnitXMLReporter

    public abstract class AbstractReporter
    extends java.lang.Object
    implements org.testng.IReporter
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static ReportMetadata META  
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractReporter​(java.lang.String classpathPrefix)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void copyClasspathResource​(java.io.File outputDirectory, java.lang.String resourceName, java.lang.String targetFileName)
      Copy a single named resource from the classpath to the output directory.
      protected void copyFile​(java.io.File outputDirectory, java.io.File sourceFile, java.lang.String targetFileName)
      Copy a single named file to the output directory.
      protected void copyStream​(java.io.File outputDirectory, java.io.InputStream stream, java.lang.String targetFileName)
      Helper method to copy the contents of a stream to a file.
      java.util.Map<java.lang.String,​java.lang.Object> createContext()  
      protected void removeEmptyDirectories​(java.io.File outputDirectory)
      Deletes any empty directories under the output directory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.testng.IReporter

        generateReport
    • Constructor Detail

      • AbstractReporter

        public AbstractReporter​(java.lang.String classpathPrefix)
    • Method Detail

      • createContext

        public java.util.Map<java.lang.String,​java.lang.Object> createContext()
      • copyClasspathResource

        protected void copyClasspathResource​(java.io.File outputDirectory,
                                             java.lang.String resourceName,
                                             java.lang.String targetFileName)
                                      throws java.io.IOException
        Copy a single named resource from the classpath to the output directory.
        Parameters:
        outputDirectory - The destination directory for the copied resource.
        resourceName - The filename of the resource.
        targetFileName - The name of the file created in outputDirectory.
        Throws:
        java.io.IOException - If the resource cannot be copied.
      • copyFile

        protected void copyFile​(java.io.File outputDirectory,
                                java.io.File sourceFile,
                                java.lang.String targetFileName)
                         throws java.io.IOException
        Copy a single named file to the output directory.
        Parameters:
        outputDirectory - The destination directory for the copied resource.
        sourceFile - The path of the file to copy.
        targetFileName - The name of the file created in outputDirectory.
        Throws:
        java.io.IOException - If the file cannot be copied.
      • copyStream

        protected void copyStream​(java.io.File outputDirectory,
                                  java.io.InputStream stream,
                                  java.lang.String targetFileName)
                           throws java.io.IOException
        Helper method to copy the contents of a stream to a file.
        Parameters:
        outputDirectory - The directory in which the new file is created.
        stream - The stream to copy.
        targetFileName - The file to write the stream contents to.
        Throws:
        java.io.IOException - If the stream cannot be copied.
      • removeEmptyDirectories

        protected void removeEmptyDirectories​(java.io.File outputDirectory)
        Deletes any empty directories under the output directory. These directories are created by TestNG for its own reports regardless of whether those reports are generated. If you are using the default TestNG reports as well as ReportNG, these directories will not be empty and will be retained. Otherwise they will be removed.
        Parameters:
        outputDirectory - The directory to search for empty directories.