-
Notifications
You must be signed in to change notification settings - Fork 12
Add your SetUps and TearDowns to Allure report
Aleksei Tiurin edited this page Feb 20, 2022
·
1 revision
First of all lets define a term condition. It's any code block that you've add
forSetUpRule
or TearDownRule
.
For example:
SetUpRule(name = "sample set up").add {
//codition code
}
It's possible to add all SetUps and TearDowns to Allure report with just a few code lines.
class CustomConditionsExecutor : DefaultConditionsExecutor(){
override fun execute(conditions: List<Condition>, keys: List<String>, description: String) {
allureStep(description){ super.execute(conditions, keys, description) }
}
}
Inside execute
method of this class you are getting a control under execution of all SetUpRule
and TearDownRule
.
So just wrap the super.execute(...)
with allure step.
The description
parameter contains the name of a rule, e.g.
SetUpRule(name = "Prepare user data with API").add {...}
2. Add custom CustomConditionExecutorWrapper
class that implements a ConditionExecutorWrapper
interface.
class CustomConditionExecutorWrapper : ConditionExecutorWrapper {
override fun execute(condition: Condition) {
allureStep(condition.name) { condition.actions() }
}
}
Inside execute
method of this class you are getting a control under all SetUpRule
and TearDownRule
conditions.
Wrap condition.actions()
with allure step.
To define proper condition.name
add it for you rule
SetUpRule(name = "sample set up").add(name = "describe condition name here") {
//codition code
}
The order of definition is important!
init {
UltronConfig.Conditions.conditionExecutorWrapper = CustomConditionExecutorWrapper()
UltronConfig.Conditions.conditionsExecutor = CustomConditionsExecutor()
}