Package com.consol.citrus.testng
Class TestNGCitrusSupport
- java.lang.Object
-
- com.consol.citrus.testng.TestNGCitrusSupport
-
- All Implemented Interfaces:
GherkinTestActionRunner,TestActionRunner,org.testng.IHookable,org.testng.ITestNGListener
public class TestNGCitrusSupport extends Object implements org.testng.IHookable, GherkinTestActionRunner
Basic Citrus TestNG support base class 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.- Author:
- Christoph Deppisch
-
-
Constructor Summary
Constructors Constructor Description TestNGCitrusSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafter()protected voidafter(CitrusContext context)Subclasses may add after test actions on the provided context.protected voidafterSuite(CitrusContext context)Subclasses may add after suite actions on the provided context.voidafterSuite(org.testng.ITestContext testContext)<T extends TestAction>
TestActionBuilder<T>applyBehavior(TestBehavior behavior)voidauthor(String author)voidbefore()protected voidbefore(CitrusContext context)Subclasses may add before test actions on the provided context.protected voidbeforeSuite(CitrusContext context)Subclasses may add before suite actions on the provided context.voidbeforeSuite(org.testng.ITestContext testContext)protected TestLoadercreateTestLoader(String testName, String packageName, String type)Creates new test loader which has TestNG test annotations set for test execution.voidcreationDate(Date date)voiddescription(String description)voidname(String name)protected TestContextprepareTestContext(TestContext testContext)Prepares the test context.<T extends TestAction>
Trun(TestActionBuilder<T> builder)voidrun(org.testng.IHookCallBack callBack, org.testng.ITestResult testResult)protected voidrun(org.testng.ITestResult testResult, Method method, List<TestLoader> methodTestLoaders, int invocationCount)Run method prepares and executes test case.voidstatus(TestCaseMetaInfo.Status status)<T> Tvariable(String name, T value)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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 Citrus citrus
Citrus instance
-
-
Method Detail
-
run
public void run(org.testng.IHookCallBack callBack, org.testng.ITestResult testResult)- Specified by:
runin interfaceorg.testng.IHookable
-
run
protected void run(org.testng.ITestResult testResult, Method method, List<TestLoader> methodTestLoaders, int invocationCount)Run method prepares and executes test case.- Parameters:
testResult-method-methodTestLoaders-invocationCount-
-
before
@BeforeClass(alwaysRun=true) public final void before()
-
before
protected void before(CitrusContext context)
Subclasses may add before test actions on the provided context.- Parameters:
context- the Citrus context.
-
after
@AfterClass(alwaysRun=true) public final void after()
-
after
protected void after(CitrusContext context)
Subclasses may add after test actions on the provided context.- Parameters:
context- the Citrus context.
-
beforeSuite
@BeforeSuite(alwaysRun=true) public final void beforeSuite(org.testng.ITestContext testContext)
-
beforeSuite
protected void beforeSuite(CitrusContext context)
Subclasses may add before suite actions on the provided context.- Parameters:
context- the Citrus context.
-
afterSuite
@AfterSuite(alwaysRun=true) public final void afterSuite(org.testng.ITestContext testContext)
-
afterSuite
protected void afterSuite(CitrusContext context)
Subclasses may add after suite actions on the provided context.- Parameters:
context- the Citrus context.
-
prepareTestContext
protected TestContext prepareTestContext(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 TestLoader createTestLoader(String testName, String packageName, String type)
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:
-
run
public <T extends TestAction> T run(TestActionBuilder<T> builder)
- Specified by:
runin interfaceTestActionRunner
-
applyBehavior
public <T extends TestAction> TestActionBuilder<T> applyBehavior(TestBehavior behavior)
- Specified by:
applyBehaviorin interfaceTestActionRunner
-
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(TestCaseMetaInfo.Status status)
-
creationDate
public void creationDate(Date date)
-
-