How to use test_add_success method in avocado

Best Python code snippet using avocado_python

run.py

Source:run.py Github

copy

Full Screen

1# --*-- coding : utf-8 --*--2# Project : python223# Current file : run.py4# Author : Administrator5# Create time : 2019-09-19 15:196# IDE : PyCharm7# TODO 成长很苦, 进步很甜, 加油!8# 初始化一个对象 suite 测试套件(集合)9import unittest10from lemon_14_190918_测试框架_unittest import test_练习相加0111from lemon_14_190918_测试框架_unittest import test_练习相减0212from lemon_14_190918_测试框架_unittest.test_练习相加01 import TestAdd13from lemon_14_190918_测试框架_unittest.test_练习相减02 import TestMinus14# 使用 TestLoader 注释下面的代码15cases = [TestAdd('test_add_success'),16 TestAdd('test_add_error'),17 TestMinus('test_add_success'),18 TestMinus('test_add_error')19 ]20# 1.初始化测试套件21suite = unittest.TestSuite(tests=cases)22'''23# 2.往套件里面添加测试用例24# addTests与addTest的区别, 第一个可以添加多个,第二个只能添加一个25# 需要一个一个去添加 TestAdd() 里面的方法名,添加字符串26# 格式:类名称(’方法名称‘)27"""28cases = [TestAdd('test_add_success'),29 TestAdd('test_add_error'),30 TestMinus('test_add_success'),31 TestMinus('test_add_error')32 ]33suite.addTests(cases)34"""35'''36# TestLoader 用来加载测试用例37# 可以根据模块加载、根据测试类加载、自己定义规则,让他们自动发现38loader = unittest.TestLoader()39# 根据测试类去加载测试用例40cases = loader.loadTestsFromTestCase(TestAdd)41cases2 = loader.loadTestsFromTestCase(TestMinus)42cases3 = loader.loadTestsFromModule(test_练习相加01)43cases4 = loader.loadTestsFromModule(test_练习相减02)44# 初始化测试套件, 往套件里面添加测试用例45suite = unittest.TestSuite()46suite.addTests(cases3)47suite.addTests(cases4)48# 运行 , 测试报告文件, demo.txt49with open('demo.txt', 'w', encoding='utf-8') as f:50 # 初始化 runner51 # stream 文件流,可以传文件52 # verbosity 详细程度53 runner = unittest.TextTestRunner(f, verbosity=0)54 # 运行...

Full Screen

Full Screen

DeleteAddress.py

Source:DeleteAddress.py Github

copy

Full Screen

...6class qgDeleteAddress(unittest.TestCase):7 def setUp(self):8 self.url = "/fgadmin/address/delete"9# 添加收货地址成功10 def test_add_success(self):11 user = {"id":77243286}12 result = SendHttp().run_http(self.url, "POST", user)13 print(result)14 self.assertEqual(result['code'], 200)15 self.assertEqual(result['message'], 'success')16# 添加收货地址失败(删除的收货地址id不存在)17 def test_add_success(self):18 user = {"id":000}19 result = SendHttp().run_http(self.url, "POST", user)20 print(result)21 self.assertEqual(result['code'], 400)22# 添加收货地址失败(删除的收货地址id类型错误)23 def test_add_success(self):24 user = {"id":"77243286"}25 result = SendHttp().run_http(self.url, "POST", user)26 print(result)27 self.assertEqual(result['code'], 400)28if __name__=='__main__':...

Full Screen

Full Screen

test_add.py

Source:test_add.py Github

copy

Full Screen

...11 def setUp(self):#前置条件12 # def __init__(self): #类的初始化13 self.b = Baiyue(s)14 self.b.login("byhy", "88888888")15 def test_add_success(self):16 name = random.randint(10, 100000)17 r = self.b.add(name).json()["ret"]18 self.assertEqual(r,0)19 # return r20 def test_add_name_error(self):21 name = random.randint(10, 100000)22 r = self.b.add("").json()["ret"]23 self.assertEqual(r, 0)24 # return r25 def test_add_name_null(self):26 name = random.randint(10, 100000)27 r = self.b.add(" ").json()["ret"]28 self.assertEqual(r, 0)29 # return r30if __name__ == '__main__':31 unittest.main()32# if __name__ == '__main__':33# t = Test_add()34# # r = t.test_add_success()35# # r = t.test_add_name_error()36# r = t.test_add_name_null()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful