Package com.consol.citrus.testng.spring
Class TestNGCitrusSpringSupport
- java.lang.Object
-
- org.springframework.test.context.testng.AbstractTestNGSpringContextTests
-
- com.consol.citrus.testng.spring.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 inTestActionRunnerandGherkinTestActionRunner. Provides Spring test listener support and loads basic Spring application context for Citrus.- Author:
- Christoph Deppisch
-
-
Constructor Summary
Constructors Constructor Description TestNGCitrusSpringSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterSuite(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)voidauthor(String author)voidbeforeSuite(org.testng.ITestContext testContext)Runs tasks before test suite.protected com.consol.citrus.common.TestLoadercreateTestLoader(String testName, String packageName)Creates new test loader which has TestNG test annotations set for test execution.voidcreationDate(Date date)voiddescription(String description)protected com.consol.citrus.TestCasegetTestCase()Constructs the test case to execute.voidname(String name)protected com.consol.citrus.context.TestContextprepareTestContext(com.consol.citrus.context.TestContext testContext)Prepares the test context.<T extends com.consol.citrus.TestAction>
Trun(com.consol.citrus.TestActionBuilder<T> builder)voidrun(org.testng.IHookCallBack callBack, org.testng.ITestResult testResult)protected voidrun(org.testng.ITestResult testResult, Method method, com.consol.citrus.common.TestLoader testLoader, int invocationCount)Run method prepares and executes test case.voidstatus(com.consol.citrus.TestCaseMetaInfo.Status status)<T> Tvariable(String name, T value)-
Methods inherited from class org.springframework.test.context.testng.AbstractTestNGSpringContextTests
setApplicationContext, springTestContextAfterTestClass, springTestContextAfterTestMethod, springTestContextBeforeTestClass, springTestContextBeforeTestMethod, springTestContextPrepareTestInstance
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
run
public void run(org.testng.IHookCallBack callBack, org.testng.ITestResult testResult)- Specified by:
runin interfaceorg.testng.IHookable- Overrides:
runin classorg.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:TestNGSuiteListenerRuns tasks before test suite.- Specified by:
beforeSuitein interfaceTestNGSuiteListener- Parameters:
testContext- the test context.
-
afterSuite
public void afterSuite(org.testng.ITestContext testContext)
Description copied from interface:TestNGSuiteListenerRuns tasks after test suite.- Specified by:
afterSuitein interfaceTestNGSuiteListener- 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:
runin interfacecom.consol.citrus.TestActionRunner
-
applyBehavior
public <T extends com.consol.citrus.TestAction> com.consol.citrus.TestActionBuilder<T> applyBehavior(com.consol.citrus.TestBehavior behavior)
- Specified by:
applyBehaviorin interfacecom.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)
-
-