python nose測試框架全面介紹十二 ----用例執行順序打亂
阿新 • • 發佈:2019-01-11
teardown odi pypi all fire code utf span 圖片
在實際執行自動化測試時,發現我們的用例在使用同一個資源的操作時,用例的執行順序對測試結果有影響,在手工測試時是完全沒法覆蓋的。
但每一次都是按用例名字來執行,怎麽打亂來執行的。
在網上看到一個有意思的插件,正好滿足我的需求,插件就簡單介紹下給需要的人吧
nose-randomly
一、安裝
pip install nose-randomly
二、安裝完成後,通過nosetests -h可以看到下面的,說明安裝成功了
三、使用
默認是按時間來做為隨機種子來打亂用例順序的,也可以自己定義種子,但這個我不需求
來使用下這個代碼測試下
#coding:utf-8 ‘‘‘ Created on 2018年8月28日 @author: huzq‘‘‘ from nose.tools import assert_in from unittest import TestCase from PIL import Image, ImageDraw, ImageFont from allure.constants import AttachmentType import sys from selenium import webdriver from nose.tools import set_trace import nose from nose.plugins.attrib import attr aa="priority" classtest_aaa(TestCase): #aa="priority=3" def setUp(self): #pass #self.web_driver = webdriver.Firefox() #self.web_driver.get("http://www.baidu.com") self.addCleanup(self.aa) #assert 1==2 def aa(self): #set_trace() print"xxxxxxxxxxxxx" @attr("priority3") def test_qqq(self): u‘afdfdfa‘ print "1111" @attr("priority2") @attr("priority3") def test_fff(self): print "2222" def tearDown(self): print "tearDwon"
使用
python nose測試框架全面介紹十二 ----用例執行順序打亂