com.hp.lft.unittesting

Class UnitTestBase

  • Direct Known Subclasses:
    TestNgUnitTestBase


    public abstract class UnitTestBase
    extends java.lang.Object
    The base class of the LeanFT Eclipse template classes provided when creating a new LeanFT project.
    • Constructor Detail

      • UnitTestBase

        public UnitTestBase()
    • Method Detail

      • classSetup

        protected void classSetup()
                           throws java.lang.Exception
        This method is called by LeanFT Eclipse templates to initialize the test class.
        Throws:
        java.lang.Exception - if error occurs during classSetup
      • classTearDown

        protected void classTearDown()
        This method is called by LeanFT Eclipse templates to clean up the test class.
      • testSetup

        protected void testSetup()
        This method is called by LeanFT Eclipse templates for operations to run before each test method.
      • parameterizedTestSetup

        protected void parameterizedTestSetup(java.lang.String testName,
                                              java.lang.String paramName)
      • testTearDown

        protected void testTearDown()
                             throws DataSourceException
        This method is called by LeanFT Eclipse templates for operations to run after each test method.
        Throws:
        DataSourceException - if error occurs in Data Source Processing
      • testTearDownNoThrow

        protected void testTearDownNoThrow()
      • getSDKConfiguration

        protected ModifiableSDKConfiguration getSDKConfiguration()
                                                          throws java.net.URISyntaxException,
                                                                 java.io.IOException
        Returns the ModifiableSDKConfiguration to use for this project. By default, uses the SDK configuration details defined in the project's leanft.properties file.
        However, if an 'lftConfigFile' system variable was specified with a valid leanft.properties file, the SDK data from that file is used to initialize the SDKConfiguration.
        Returns:
        the ModifiableSDKConfiguration to use for this project
        Throws:
        java.net.URISyntaxException - if the syntax of the URI is invalid.
        java.io.IOException - if error occurs in I/O operations
      • getReportConfiguration

        protected ModifiableReportConfiguration getReportConfiguration()
                                                                throws java.net.URISyntaxException,
                                                                       java.io.IOException
        Returns the ModifiableReportConfiguration to use for this project. By default, uses the Report configuration details defined in the project's leanft.properties file.
        However, if an 'lftConfigFile' system variable was specified with a valid leanft.properties file, the Report data from that file is used to initialize the SDKConfiguration.
        Returns:
        the ModifiableReportConfiguration to use for this project
        Throws:
        java.net.URISyntaxException - if the syntax of the URI is invalid.
        java.io.IOException - if error occurs in I/O operations
      • getAlmData

        protected static java.lang.Iterable<java.lang.String[]> getAlmData()
                                                                    throws java.lang.Exception
        Returns the collection of parameterized test parameter values extracted from data resource on ALM server.
        Returns:
        the collection of parameterized test parameter values extracted from data resource on ALM server.
        Throws:
        java.lang.Exception - if error occurs in the ALM Data process
      • getDefaultReportConfiguration

        protected static ReportConfiguration getDefaultReportConfiguration()
        Returns the default report configuration.
        Returns:
        the default report configuration.
      • getReportConfigurationFromResourcesPropertiesFile

        protected static ReportConfiguration getReportConfigurationFromResourcesPropertiesFile(java.lang.String propertiesFileName)
                                                                                        throws java.io.IOException
        Returns the report configuration with values from the specified leanft.properties file in the resources folder.
        Parameters:
        propertiesFileName - the name of the properties file to use (the file must be in the resources folder).
        Returns:
        the report configuration
        Throws:
        java.io.IOException - if error occurs in I/O operations
      • getReportConfigurationFromExternalPropertiesFile

        protected static ReportConfiguration getReportConfigurationFromExternalPropertiesFile(java.lang.String propertiesFilePath)
                                                                                       throws java.io.IOException
        Returns the report configuration with values from the specified leanft.properties file.
        Parameters:
        propertiesFilePath - the full path of the properties file to use.
        Returns:
        the report configuration
        Throws:
        java.io.IOException - if error occurs in I/O operations
      • getFrameworkClassName

        protected java.lang.String getFrameworkClassName()
        Returns the testing project class name.
        Returns:
        the testing project class name.
      • getFrameworkClassName

        protected java.lang.String getFrameworkClassName(boolean removeCaseChars)
        Returns the testing project class name. If an empty or null value is returned, use the alternative class name.
        Parameters:
        removeCaseChars - remove case characters
        Returns:
        the testing project class name.
      • getFrameworkTestName

        protected java.lang.String getFrameworkTestName()
        Returns the test method name.
        Returns:
        the test method name.
      • getFrameworkTestName

        protected java.lang.String getFrameworkTestName(boolean removeCaseChars)
        Returns the framework test name. If an empty or null value is returned, use the alternative framework name.
        Parameters:
        removeCaseChars - remove case characters
        Returns:
        the test framework name.
      • getAlternativeTestName

        protected java.lang.String getAlternativeTestName()
        Returns the alternative test name that is used whenever framework errors occur.
        Note: This can be useful to set the start and end points of a test in your class if the runner you are using does not successfully pass LeanFT test names to the LeanFT report.
        In this case, by default the LeanFT report displays: [Undefined]. Override to provide an alternative test method name.
        Returns:
        the alternative test name that is used whenever framework errors occur.
      • getAlternativeClassName

        protected java.lang.String getAlternativeClassName()
        Returns the alternative class name that is used whenever framework errors occur.
        Note: This can be useful to set the start and end points of a test in your class if the runner you are using does not successfully pass LeanFT test names to the LeanFT report.
        In this case, by default the LeanFT report displays: [Undefined]. Override to provide an alternative test method name.
        Returns:
        the alternative class name that is used whenever framework errors occur.
      • getClassName

        protected abstract java.lang.String getClassName()
        Returns the class name.
        Returns:
        the class name.
      • getTestName

        protected abstract java.lang.String getTestName()
        Returns the test method name.
        Returns:
        the test method name.
      • setStatus

        protected void setStatus(Status status)
        Sets the Status of the Reporter.
        Parameters:
        status - the new report status
      • setStatus

        protected void setStatus(Status status,
                                 java.lang.Throwable throwable)
        Sets the Status of the Reporter and provides the Throwable as the failure reason (relevant to Failed status only).
        Parameters:
        status - the new report status
        throwable - the failure reason