class TestSearch: """ pytest test_search.py --alluredir ../allureresult --clean-alluredir allure serve ../allureresult """ def setup(self): self.app = App() # self.app.start() # @pytest.mark.parametrize() def test_search(self): # App类里的start方法有return self,所以这里可以直接链式调用goto_main self.app.start().goto_main().goto_market().goto_search().search()
class TestCase: def setup_class(self): print("setup开始") self.app = App() def teardown_class(self): print("teardown结束") self.app.quit() @allure.testcase("http://www.baidu.com", "测试用例的链接") @allure.story("搜索成功") def test_search(self): self.app.start() self.app.goto_main_page().goto_market_page().goto_search_page( ).opt_search() allure.attach("测试日志内容", "测试日志标题", attachment_type=allure.attachment_type.TEXT)
class TestContact: def setup(self): self.app = App() self.main = self.app.start().goto_main() def teardown(self): self.app.stop() @pytest.mark.parametrize("name,gender,phonenum", get_data()) def test_add_contact(self, name, gender, phonenum): toast = self.main.click_addresslist().add_member().addcontact_menual(). \ edit_name(name).edit_gender(gender).edit_phonenum(phonenum).click_save().get_toast() assert toast == '添加成功'
def test_mine(): app = App() result = app.start().gotoMain().goto_me()
def test_search(): app = App() result = app.start().gotoMain().goto_market().goto_search().search() assert result
class TestSearch: def setup(self): self.app = App() def test_search(self): self.app.start().goto_main().goto_market().goto_search().search()
def test_mine(): app = App() app.start().goto_main().goto_mine()