Package guru.mikelue.jdut.testng
Class ISuiteYamlFactoryListener
- java.lang.Object
-
- guru.mikelue.jdut.testng.YamlFactoryListenerBase
-
- guru.mikelue.jdut.testng.ISuiteYamlFactoryListener
-
- All Implemented Interfaces:
ISuiteListener
,ITestNGListener
public class ISuiteYamlFactoryListener extends YamlFactoryListenerBase implements ISuiteListener
This listener uses file name(classpath:<suite_name>.yaml
for resource(ClassLoader
of current thread) of conducting data.By default, the
DataSource
would be retrieved fromISuite
object(which type ofIAttributes
).Example by defulat conventions:
package guru.mikelue.jdut.testng.example; // File: classpath:BullSharkSuite.yaml @Test(suiteName="BullSharkSuite") @Listeners(BullSharkTest.BullSharkSuiteListener.class) public class BullSharkTest { public static BullSharkSuiteListener extends ISuiteYamlFactoryListener { @Override public void onStart(ISuite suite) { YamlFactoryListenerBase.setDataSource(suite, SuiteListenerForAppContext.getDataSource(suite)); super.onStart(suite); } @Override public void onFinish(ISuite suite) { super.onFinish(suite); YamlFactoryListenerBase.removeDataSource(suite); } } @Test public void bite() { } }
-
-
Constructor Summary
Constructors Constructor Description ISuiteYamlFactoryListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Optional<DuetConductor>
buildDuetConductor(IAttributes attributes)
Builds the conductor from data source inISuite
.protected boolean
needConductData(ISuite suite)
Checks whether or not the suite should make.
By default, this method always returns true.void
onFinish(ISuite suite)
ExecutesduetConductorClean
if the result ofneedConductData(org.testng.ISuite)
is true.void
onStart(ISuite suite)
ExecutesduetConductorBuild
if the result ofneedConductData(org.testng.ISuite)
is true.-
Methods inherited from class guru.mikelue.jdut.testng.YamlFactoryListenerBase
buildYamlConductorFactory, duetConductorBuild, duetConductorClean, getDataSource, getLogger, removeDataSource, setDataSource
-
-
-
-
Method Detail
-
onFinish
public void onFinish(ISuite suite)
ExecutesduetConductorClean
if the result ofneedConductData(org.testng.ISuite)
is true.- Specified by:
onFinish
in interfaceISuiteListener
- Parameters:
suite
- The suite provided by TestNG framework
-
onStart
public void onStart(ISuite suite)
ExecutesduetConductorBuild
if the result ofneedConductData(org.testng.ISuite)
is true.- Specified by:
onStart
in interfaceISuiteListener
- Parameters:
suite
- The suite provided by TestNG framework
-
buildDuetConductor
protected Optional<DuetConductor> buildDuetConductor(IAttributes attributes)
Builds the conductor from data source inISuite
.- Specified by:
buildDuetConductor
in classYamlFactoryListenerBase
- Parameters:
attributes
- The object ofISuite
- Returns:
- The initialized conductor or nothing
-
needConductData
protected boolean needConductData(ISuite suite)
Checks whether or not the suite should make.
By default, this method always returns true.- Parameters:
suite
- The suite data- Returns:
- true if this suite should apply data conduction
-
-