Unittest简单应用

#_*_coding:utf8_*_

import unittest
from selenium import webdriver
import time class Test_apiTest(unittest.TestCase):
def setUp(self): #相当于python __init__ 加载时运行 相当于构造函数
self.driver = webdriver.Ie()
self.url = "http://www.baidu.com" def tearDown(self): #相当于python __del__ 结束于运行 相当于析构函数
self.driver.quit() def test_searchBD(self): #测试方法,必须以test开头
ie = self.driver.get(self.url)
self.driver.find_element_by_id('kw').send_keys('selenium')
self.driver.find_element_by_id('su').click() if __name__ == '__main__':
#unittest.main() suite = unittest.TestSuite() #实例一个套件
suite.addTest(Test_apiTest().test_searchBD()) #将测试Case方法增加入套件,如果有多个Test Case可以多次增加。
unittest.TextTestRunner().run(suite)#执行测试 执行测试Case的顺序,跟suite.addTest顺序先后有关。

Unittest + python的更多相关文章

  1. Unittest - Python 使用总结

    Unittest - Python 使用总结 批量执行 一.UnitTest TestSuite 控制用例执行的顺序 UnitTest 框架默认 main() 方法根据 ASCII 码的顺序加载测试用 ...

  2. unittest (python标准库-开发工具-单元测试框架)

    unittest官方文档摘录 翻译 reffer to: https://docs.python.org/3/library/unittest.html#unittest.TextTestRunner ...

  3. <自动化测试>之<使用unittest Python测试框架进行参数化测试>

    最近在看视频时,虫师简单提到了简化自动化测试脚本用例中的代码量,而python中本身的参数化方法用来测试很糟糕,他在实际操作中使用了parameterized参数化... 有兴趣就查了下使用的方法,来 ...

  4. 在pycharm进行单元测试(unittest python)

    在Edit Configuration中添加Python test 选中相应的脚本或者文件夹 # coding:utf-8 import unittest import requests from c ...

  5. Appium+unittest+python登录app

    代码: # coding=utf-8 from appium import webdriver import time import unittest import os import HTMLTes ...

  6. [转]Python测试框架对比----unittest, pytest, nose, robot framework对比

      测试框架 什么是框架? 框架(Framework)是整个或部分系统的可重用设计,框架是用来解决代码的组织及运行控制问题的. 在我们编写自动化脚本的时候,经常需要读取配置文件,读取数据文件,发送请求 ...

  7. python学习笔记:unittest单元测试

    单元测试:开发自测时写的代码 unittest基本原理: ♦整个平台的搭建使用的是python的unittest测试框架,这里简单介绍下unittest模块的简单应用. ♦unittest是pytho ...

  8. python学习笔记(27)-unittest单元测试-测试用例

    单元测试 #单元测试 #unittest+接口 unittest python自带 pytest+jenkins+allure #接口测试的本质 就是测试类里面的函数 #单元测试的本质 测试函数 代码 ...

  9. Python测试框架对比----unittest, pytest, nose, robot framework对比

    什么是框架? 框架(Framework)是整个或部分系统的可重用设计, 框架是用来解决代码的组织及运行控制问题的. 在我们编写自动化脚本的时候,经常需要读取配置文件,读取数据文件,发送请求,记录日志, ...

随机推荐

  1. C和C指针小记(八)-操作符、左值右值

    1.移位操作符 移位操作符分为左移操作符(<<)和右移操纵符(>>) 对于无符号数:左右位移操作都是逻辑位移 对于有符号数:到底是采用逻辑位移还是算术位移取决于编译器.如果一个 ...

  2. Exception 04 : java.lang.ClassNotFoundException: Could not load requested class : org.hsqldb.jdbcDriver

    异常详细信息 org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org ...

  3. [development] __attribute__((weak))是干嘛的

    简单的说,就是当发生 “重复定义的时候”.被声明者会被冲突者覆盖掉. 这里还涉及了weak与alias连用的情况. 参见,里边有两个例子,很浅显易懂. https://my.oschina.net/s ...

  4. Scaleform Gfx的Demo

    转载:http://www.xuebuyuan.com/2167614.html 新建一个Demo工程时,编译之前有一些VS的配置是必须的,在Debug和Release下,工程必须包括: $(GFXS ...

  5. cocos2dx 常用的构建工具

    理编辑工具Physics Editing ToolsMekanimo 网址:http://www.mekanimo.net/PhysicsBench 网址:http://www.cocos2d-iph ...

  6. LeetCode 872 Leaf-Similar Trees 解题报告

    题目要求 Consider all the leaves of a binary tree.  From left to right order, the values of those leaves ...

  7. vue-loader是什么?使用它的用途有哪些?

    vue-loader是解析 .vue 文件的一个加载器,跟 template/js/style转换成 js 模块: 用途:js可以写es6.style样式可以scss或less:template可以加 ...

  8. Spring 配置文件出现异常!

    spring配置文件错误 Referenced file contains errors (http://www.springframework.org/schema/beans/spring-bea ...

  9. python练习题-day4

    1.写代码,有如下列表,按照要求实现每一个功能 li = ["alex", "WuSir", "ritian", "barry&q ...

  10. windows无法安装到这个磁盘。选中的磁盘采用GPT分区形式 Windows 检测到 EFI 系统分区格式化为 NTFS。将 EFI 系统分区个数化为 FAT32,然后重新启动安装

    win10安装问题解决 问题 1.windows无法安装到这个磁盘.选中的磁盘采用GPT分区形式 解决方法: 1.bios,更改 uefi/legacy boot 为ueei only 后面可以安装了 ...