Class TestNGCitrusSpringSupport

  • All Implemented Interfaces:
    com.consol.citrus.GherkinTestActionRunner, com.consol.citrus.TestActionRunner, TestNGSuiteListener, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.testng.IHookable, org.testng.ITestNGListener

    @ContextConfiguration(classes=com.consol.citrus.config.CitrusSpringConfig.class)
    public class TestNGCitrusSpringSupport
    extends org.springframework.test.context.testng.AbstractTestNGSpringContextTests
    implements com.consol.citrus.GherkinTestActionRunner, TestNGSuiteListener
    Basic Citrus TestNG support base class with Spring support automatically handles test case runner creation. Also provides method parameter resolution and resource injection. Users can just extend this class and make use of the action runner methods provided in TestActionRunner and GherkinTestActionRunner. Provides Spring test listener support and loads basic Spring application context for Citrus.
    Author:
    Christoph Deppisch
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.consol.citrus.Citrus citrus
      Citrus instance
      protected org.slf4j.Logger log
      Logger
      • Fields inherited from class org.springframework.test.context.testng.AbstractTestNGSpringContextTests

        applicationContext, logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterSuite​(org.testng.ITestContext testContext)
      Runs tasks after test suite.
      <T extends com.consol.citrus.TestAction>
      com.consol.citrus.TestActionBuilder<T>
      applyBehavior​(com.consol.citrus.TestBehavior behavior)  
      void author​(String author)  
      void beforeSuite​(org.testng.ITestContext testContext)
      Runs tasks before test suite.
      protected com.consol.citrus.common.TestLoader createTestLoader​(String testName, String packageName)
      Creates new test loader which has TestNG test annotations set for test execution.
      void creationDate​(Date date)  
      void description​(String description)  
      protected com.consol.citrus.TestCase getTestCase()
      Constructs the test case to execute.
      void name​(String name)  
      protected com.consol.citrus.context.TestContext prepareTestContext​(com.consol.citrus.context.TestContext testContext)
      Prepares the test context.
      <T extends com.consol.citrus.TestAction>
      T
      run​(com.consol.citrus.TestActionBuilder<T> builder)  
      void run​(org.testng.IHookCallBack callBack, org.testng.ITestResult testResult)  
      protected void run​(org.testng.ITestResult testResult, Method method, com.consol.citrus.common.TestLoader testLoader, int invocationCount)
      Run method prepares and executes test case.
      void status​(com.consol.citrus.TestCaseMetaInfo.Status status)  
      <T> T variable​(String name, T value)  
      • Methods inherited from class org.springframework.test.context.testng.AbstractTestNGSpringContextTests

        setApplicationContext, springTestContextAfterTestClass, springTestContextAfterTestMethod, springTestContextBeforeTestClass, springTestContextBeforeTestMethod, springTestContextPrepareTestInstance
      • Methods inherited from interface com.consol.citrus.GherkinTestActionRunner

        and, and, given, given, then, then, when, when
      • Methods inherited from interface com.consol.citrus.TestActionRunner

        $, $, run
    • Field Detail

      • log

        protected final org.slf4j.Logger log
        Logger
      • citrus

        protected com.consol.citrus.Citrus citrus
        Citrus instance
    • Constructor Detail

      • TestNGCitrusSpringSupport

        public TestNGCitrusSpringSupport()
    • Method Detail

      • run

        public void run​(org.testng.IHookCallBack callBack,
                        org.testng.ITestResult testResult)
        Specified by:
        run in interface org.testng.IHookable
        Overrides:
        run in class org.springframework.test.context.testng.AbstractTestNGSpringContextTests
      • run

        protected void run​(org.testng.ITestResult testResult,
                           Method method,
                           com.consol.citrus.common.TestLoader testLoader,
                           int invocationCount)
        Run method prepares and executes test case.
        Parameters:
        testResult -
        method -
        testLoader -
        invocationCount -
      • beforeSuite

        public void beforeSuite​(org.testng.ITestContext testContext)
        Description copied from interface: TestNGSuiteListener
        Runs tasks before test suite.
        Specified by:
        beforeSuite in interface TestNGSuiteListener
        Parameters:
        testContext - the test context.
      • afterSuite

        public void afterSuite​(org.testng.ITestContext testContext)
        Description copied from interface: TestNGSuiteListener
        Runs tasks after test suite.
        Specified by:
        afterSuite in interface TestNGSuiteListener
        Parameters:
        testContext - the test context.
      • prepareTestContext

        protected com.consol.citrus.context.TestContext prepareTestContext​(com.consol.citrus.context.TestContext testContext)
        Prepares the test context. Provides a hook for test context modifications before the test gets executed.
        Parameters:
        testContext - the test context.
        Returns:
        the (prepared) test context.
      • createTestLoader

        protected com.consol.citrus.common.TestLoader createTestLoader​(String testName,
                                                                       String packageName)
        Creates new test loader which has TestNG test annotations set for test execution. Only suitable for tests that get created at runtime through factory method. Subclasses may overwrite this in order to provide custom test loader with custom test annotations set.
        Parameters:
        testName -
        packageName -
        Returns:
      • getTestCase

        protected com.consol.citrus.TestCase getTestCase()
        Constructs the test case to execute.
        Returns:
      • run

        public <T extends com.consol.citrus.TestAction> T run​(com.consol.citrus.TestActionBuilder<T> builder)
        Specified by:
        run in interface com.consol.citrus.TestActionRunner
      • applyBehavior

        public <T extends com.consol.citrus.TestAction> com.consol.citrus.TestActionBuilder<T> applyBehavior​(com.consol.citrus.TestBehavior behavior)
        Specified by:
        applyBehavior in interface com.consol.citrus.TestActionRunner
      • variable

        public <T> T variable​(String name,
                              T value)
      • name

        public void name​(String name)
      • description

        public void description​(String description)
      • author

        public void author​(String author)
      • status

        public void status​(com.consol.citrus.TestCaseMetaInfo.Status status)
      • creationDate

        public void creationDate​(Date date)