zoukankan      html  css  js  c++  java
  • python nose测试框架全面介绍十二 ----用例执行顺序打乱

    在实际执行自动化测试时,发现我们的用例在使用同一个资源的操作时,用例的执行顺序对测试结果有影响,在手工测试时是完全没法覆盖的。

    但每一次都是按用例名字来执行,怎么打乱来执行的。

    在网上看到一个有意思的插件,正好满足我的需求,插件就简单介绍下给需要的人吧

    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"
    
    class test_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"
            
                
        

    使用

      

  • 相关阅读:
    web--ajax--json
    4.26
    4.25
    4.23
    4.22
    4.20
    4.19
    4.18
    4月问题总结章
    4.17
  • 原文地址:https://www.cnblogs.com/landhu/p/10255640.html
Copyright © 2011-2022 走看看