-
Notifications
You must be signed in to change notification settings - Fork 40
Approach to nested step in async tests #6
Comments
Suggestion # 1 - add startStep(), endStep() methodsExample: var step = allure.startStep('Outer step');
element.click().then(function () {
//nesting - invoking createStep() on step, not on allure
step.createStep('Step inside of promise', function () {})();
}).then(function(){
step.endStep('pass');
}).thenCatch(function(){
step.endStep('failed');
}); In the end all the non-finished steps are marked as passed (or as failed to notify about bugs in tests). |
I got the point. I have the suggestion too: Suggestion # 2 – await promise returned from a step function.var bigStep = allure.createStep('make some clicks', function() {
return clickStep()
.then(clickStep)
.then(clickStep);
});
var clickStep = allure.createStep('click', function() {
return element.click(); // if promise returned, we will wait this before finish the step
});
it('should make three clicks', function() {
return bigStep();
}); Most webdrivers libraries as far as I know, support promised interfaces, to that code would more natural for them |
also, allure._allure.startStep('my step');
allure._allure.finishStep('broken'); You can play around that methods in existing tests code and find out better solution |
Suggestion # 2 looks cool from the API perspective. These concerns come to my mind:
PS: |
Released as
If you omit explicit |
also I am going to update my example with mocha – https://github.com/allure-examples/mocha-allure-example |
Currently it's impossible to nest steps in a lot of cases when async tests are used. Consider this Protractor code that uses Promises:
While the code is nested, it's actually executed in Control Flow of WebdriverJS and therefore zeroes out all the nestiness.
Because this is a usual thing in WebdriverJS I'd think on general approach to address this.
The text was updated successfully, but these errors were encountered: