参数化和数据驱动
参数化和数据驱动 摘要: 参数化的使用 pytest.mark.parametrize()直接传参 数据驱动 外部文件:使用yaml 测试用例参数从外部文件获取 测试步骤从外部文件获取 参数化使用 @pytest.mark.parametrize(“search_words”, [‘游戏’, “hhdddx”]) 具体用例: from page . app import App class TestDemo : def setup ( self ) : self . main_page = App . start ( ) @pytest . mark . dependency ( ) def test_game_handle ( self ) : '''点击首页的游戏手柄,进入游戏中心''' self . game_center = self . main_page . click_game_handle ( ) # @pytest.mark.dependency(depends=["TestDemo::test_game_handle"]) @pytest . mark . parametrize ( "keyword" , [ '游戏' , "hhdddx" ] ) def test_game_search ( self , keyword ) : self . test