4

I am looking for solution where I can group test steps in allure report.

Currently what is happening :

For example I have one test case login where there are 5 steps i.e go to login page, enter login detail, click on submit etc. But in allure report I want to show only 1 steps for all 5 login actions. is it possible?

So basically I want to display test case as steps and not scenarios as steps in report.

I searched a lot but did not find a way to do this with allure.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
Helping Hands
  • 5,292
  • 9
  • 60
  • 127

1 Answers1

6

You can call the functions inside allure.step block

@pytest.mark.sanity
class TestExample:

    def test_example(self):
        with allure.step('Do Login'):
            self.go_to_login_page()
            self.insert_user_name()
            self.insert_password()

    def go_to_login_page(self):
        Report.report_step('go to login page')

    def insert_user_name(self):
        Report.report_step('insert username')

    def insert_password(self):
        Report.report_step('insert password')

Or with page object

@pytest.mark.sanity
class TestExampleTest:

    def test_example(self):
        with allure.step('Do Login'):
            (LoginPage()
             .go_to_login_page()
             .insert_user_name()
             .insert_password())


class LoginPage:

    def go_to_login_page(self):
        Report.report_step('go to login page')
        return self

    def insert_user_name(self):
        Report.report_step('insert username')
        return self

    def insert_password(self):
        Report.report_step('insert password')
        return self

report_step is a static function in Report.py file

def report_step(step_title):
    with allure.step(step_title):
        pass

The steps will be grouped inside 'Do Login' step

enter image description here

enter image description here

Edit Same idea with Java

public class Test {
    public void testMethod() {
        doLogin();
    }

    @Step("Do Login")
    public void doLogin() {
        new LoginPage()
                .goToLoginPage()
                .insertUserName("NAME")
                .insertPassword("PASSWORD");
    }
}

public class LoginPage {

    @Step("Go to login page")
    public LoginPage goToLoginPage() {
       step("goToLoginPage");
       return this;
    }

    @Step("Insert user name {userName}")
    public LoginPage insertUserName(String userName) {
       return this;
    }

    @Step("Insert password {password}")
    public LoginPage insertPassword(String password) {
        return this;
    }
}
Guy
  • 46,488
  • 10
  • 44
  • 88