测试总结:采用Xmind对项目进行了界面、功能、兼容性、性能、安全性测试用例的编写,项目测试主要是测试功能以黑盒测试为主,还进行了界面测试、兼容性测试、自动化测试。
自动化测试采用了unittest框架分别测试了共17个用例,注册功能部分代码10个用例,登录部分代码7个用例,自动化测试脚本都成功运行。
?手工测试:https://kdocs.cn/l/cl9Zo5Oa1ZSx
测试总结:一共使用了2个浏览器(Chrome和Firefox)手工测试了30个测试用例,测试用例覆盖率达到了73.17%,注册部分测试了15个测试用例,发现6个次要性BUG 2个一般性BUG,登录部分测试了11个测试用例,发现2个一般性BUG,聊天主页测试了4个用例,发现1个次要BUG。总共发现11个BUG,均不影响项目的正常使用。
一、测试用例
?
二、自动化测试
(1)注册部分功能测试代码
from selenium import webdriver
import unittest
import time
class Register(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(10)
self.base_url = "http://81.70.104.245:8888/register.html"
self.driver.maximize_window()
self.verificationErrors = []
self.accept_next_alert = True
# 测试注册时已经存在用户名是否注册成功
def test_01_register_username(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("111")
driver.find_element_by_id("nickname").send_keys("测试已经存在的用户名")
driver.find_element_by_id("password").send_keys("123456")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试注册时已经存在昵称是否注册成功
def test_02_register_nickname(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test123456")
driver.find_element_by_id("nickname").send_keys("测试已经存在的用户名")
driver.find_element_by_id("password").send_keys("yao123456")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试已经存在的密码是否注册成功
def test_03_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test1234567")
driver.find_element_by_id("nickname").send_keys("测试密码")
driver.find_element_by_id("password").send_keys("yao123456")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试未注册过的用户名、昵称、密码
def test_04_register_all(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test12345")
driver.find_element_by_id("nickname").send_keys("测试all")
driver.find_element_by_id("password").send_keys("yao12345")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试6位英文密码
def test_05_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test01")
driver.find_element_by_id("nickname").send_keys("测试01")
driver.find_element_by_id("password").send_keys("asdfgh")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试7位数标点符号密码
def test_06_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test02")
driver.find_element_by_id("nickname").send_keys("测试02")
driver.find_element_by_id("password").send_keys("@#@@#@#")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试16位数字+英文密码
def test_07_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test03")
driver.find_element_by_id("nickname").send_keys("测试03")
driver.find_element_by_id("password").send_keys("zhiqiangyao11111")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试17位数字+标点符号密码
def test_08_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test04")
driver.find_element_by_id("nickname").send_keys("测试04")
driver.find_element_by_id("password").send_keys("zhiqiangyao@#¥%&!")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试18位数字+英文+标点符号密码
def test_09_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test05")
driver.find_element_by_id("nickname").send_keys("测试05")
driver.find_element_by_id("password").send_keys("zhiqiangyao@123456")
driver.find_element_by_xpath("/html/body/div[1]/form/div[4]/input").click()
time.sleep(5)
# 测试界面下的登录按钮是否正常跳转
def test_10_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_xpath("/html/body/div[2]/p/a").click()
time.sleep(5)
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main(verbosity=2)
(2)登录功能部分测试代码
from selenium import webdriver
import unittest
import time
class Login(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(10)
self.base_url = "http://81.70.104.245:8888/login.html"
self.driver.maximize_window()
self.verificationErrors = []
self.accept_next_alert = True
# 登录时输入正确的用户名和密码的情况
def test_01_login_right(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test12345")
driver.find_element_by_id("password").send_keys("yao12345")
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(5)
# 登录时输入正确的用户名错误的密码
def test_02_login_username_right(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test12345")
driver.find_element_by_id("password").send_keys("error12345")
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(5)
# 登录时只输入错误的用户名,正确的密码
def test_03_register_password_right(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("error12345")
driver.find_element_by_id("password").send_keys("yao12345")
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(5)
# 登录时只输入正确的用户名
def test_04_login_username_right(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("test12345")
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(3)
# 登录时不输入用户名和密码
def test_05_login_null(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(3)
# 登录时输入不存在的用户名和密码的情况
def test_06_register_error_all(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("username").send_keys("不存在123456789")
driver.find_element_by_id("password").send_keys("789456123")
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(5)
# 测试界面下的注册按钮是否正常跳转
def test_07_register_password(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_xpath("/html/body/div[1]/form/div[2]/input").click()
time.sleep(5)
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main(verbosity=2)
|