在UI自動化測試中使用flaky外掛程式運行失敗用例

來源:互聯網
上載者:User

標籤:frame   failed   環境   pre   att   href   詳細說明   2016年   bsp   

在UI自動化測試中,有時候經常會提示跑用例失敗,在單步或單個用例調試時,用例卻成功,這個失敗的因素主要有環境、代碼或前端定位等原因。

可以看這篇文章《我們是如何讓UI測試變得穩定的》中有詳細說明,但是,在這裡,我們不討論問題,我們來看看最佳化

 

項目中原來的自動化架構是基本nose的,nose中有一個選項為:

--failed              Run the tests that failed in the last test run.

可以單獨運行上次測試中失敗的用例,但貌似與我的想法有點背離,我的需求是失敗後再運行一次用例,然後報告可以正常輸出

無專屬偶,正好看到有一個flaky可以支援這種需求,具體的介紹和安裝,有前輩寫了:http://blog.csdn.net/liuchunming033/article/details/45916389

 

但在nose架構中有點差異,如下:

#coding:utf-8‘‘‘Created on 2016年6月22日@author: huzq‘‘‘from  nose.tools import with_setupimport loggingfrom test_case import newfrom nose.tools import ok_from nose.tools import eq_import noseimport osfrom nose.plugins.attrib import attrfrom nose.plugins.skip import SkipTestimport sysfrom pdb import set_trace#TODO:jfjfjflog = logging.getLogger(__name__)@attr(mode=1) def test_learn_1():    u‘‘‘測試取消‘‘‘    print ‘xxx‘    #raise SkipTest    #print "test_lean_1"    #pass    #assert 1==2    eq_(6, 7, msg=u"錯誤")@attr(mode=2) def test_lean_2():    u‘‘‘測試失敗‘‘‘    try:        print "test_learn_2"        ok_(4==3,msg="xxx")        print sys._getframe().f_code.co_name    except Exception:        print sys._getframe().f_code.co_name            @attr(mode=2) def test_lean_3():    u‘‘‘測試成功‘‘‘    pass     def setUp():    #set_trace()    print "0001 test setUp"    def tearDown():    print "0001 test teardown"

使用flaky方法如下:

E:\workspace\nosetest_lear\test_case>nosetests -v test_case_0001.py --with-flaky   #帶flaky運行,預設運行一次,最後會輸出flaky簡要報告E:\workspace\nosetest_lear\test_case>nosetests -v test_case_0001.py --with-flaky  --no-flaky-report    #沒有flaky報告輸出E:\workspace\nosetest_lear\test_case>nosetests -v test_case_0001.py --with-flaky --no-flaky-report  --max-runs=3 --min-passes=1 #成功後只運行一次,失敗後運行2次

  

在UI自動化測試中使用flaky外掛程式運行失敗用例

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.