Hel*_*nds 4 selenium-webdriver allure
我正在寻找可以在诱惑报告中对测试步骤进行分组的解决方案。
目前正在发生的事情:
例如,我有一个测试用例登录,其中有 5 个步骤i.e go to login page, enter login detail, click on submit etc.但在诱惑报告中,我只想显示所有 5 个登录操作的 1 个步骤。是否可以?
所以基本上我想将测试用例显示为步骤而不是场景作为报告中的步骤。
我搜索了很多,但没有找到一种有诱惑力的方法。
您可以调用allure.step块内的函数
@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')
Run Code Online (Sandbox Code Playgroud)
或者使用页面对象
@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
Run Code Online (Sandbox Code Playgroud)
report_step是Report.py文件中的静态函数
def report_step(step_title):
with allure.step(step_title):
pass
Run Code Online (Sandbox Code Playgroud)
这些步骤将在'Do Login'步骤内分组
用 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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2423 次 |
| 最近记录: |