• 测试这些肯定需要用到相关的硬件仪器设备的,像安捷纶测试电流电压,欧姆表测电阻,你找人学学应该不难的

  • 最好是抓包,查看前端发送数据以及后端返回数据,如果是前端发送数据参数有误,请求不到后端通常报 401,如果是后端返回出错,通常是报 500,具体情况还得具体分析

  • 嗯,谢谢了,受教了

  • 明白了,我自己再重新修改修改看看,谢谢啦,如果改不了再过来请教😅

  • import time
    import unittest
    
    
    from common.common import *
    import yaml
    from ddt import ddt,file_data,data,unpack
    
    
    #此测试用例主要验证登录接口以及进入系统后获取的一些初始化接口数据
    
    
    @ddt
    class MyTestCase(unittest.TestCase):
    
        @classmethod
        def setUpClass(cls):
            cls.baseapi = CommonApi()
            cls.token = None
            cls.userCode = None
            cls.url = None
            cls.headers = ''
    
        @classmethod
        def tearDownClass(cls):
            pass
    
        #客户端登录
        @file_data('../data/user.yaml')
        def test1_login(self,**kwargs):
            path = '/api/uc/public/v2new/account/login'
            url = kwargs.get('url')
            data = kwargs.get('data')
            headers = kwargs.get('headers')
            loginresult = self.baseapi.post(url=url+path,data=data,headers=headers)
            MyTestCase.token = loginresult.json()['data']['token']
            MyTestCase.userCode = loginresult.json()['data']['userCode']
            MyTestCase.url = url
            headers['Authorization'] = self.token
            MyTestCase.headers = headers
            self.assertEqual(loginresult.json()['msg'],'操作成功','登录失败')
    
        #查询某机构下员工详细列表
        def test2_friendUserInfo(self):
            path = '/api/user/v1/friendUserInfo/queryAppEmployeeDetailInfoList'
            data = {
                "employeeCodeList": []
            }
            friendUserInforesult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(friendUserInforesult.json()['msg'],'操作成功','获取好友信息列表失败')
            MyTestCase.url = self.url
    
        #查看员工个人信息/好友关系
        def test3_getUserInfo(self):
            path = '/api/uc/org/employee/v1/getEmpPerAndFriUserInfoNotPermission'
            data ={
                'employeeCode': self.userCode
            }
            getUserInforesult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(getUserInforesult.json()['msg'],'操作成功','获取个人信息失败')
    
        #登录IM
        def test4_imlogin(self):
            path = '/api/work-im/public/v1/app/login/'
            data = {
                "platform": 1,
                "code": "66666",
                "clientId": "55ED93CB-0DE2-46CA-896C-4FF9055C0956",
                 "userCode": self.userCode
            }
            imloginresult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(imloginresult.json()['msg'],'操作成功','登录IM成功')
    
        #获取群聊
        @unittest.skip('暂时无法执行,先跳过')
        def test5_groupByUser(self):
            path = '/api/work/im/v1/app/group/groupByUser/'
            params = ''
            groupByUserresult = self.baseapi.get(url=self.url+path+self.userCode,params=params,headers=self.headers)
            print(groupByUserresult.json())
    
        #查询我的好友列表
        def test6_friendRequest(self):
            path = '/api/user/v1/friendRequest/queryAllFriend'
            data = {
                "pageSize": 10000,
                "pageNo": 1,
                "contactCode": self.userCode
            }
            friendRequestresult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(friendRequestresult.json()['msg'],'操作成功','获取好友数据失败')
    
        #查询某机构下员工详细列表带用户ID
        def test7_friendUserInfo(self):
            path = '/api/user/v1/friendUserInfo/queryAppEmployeeDetailInfoList'
            data = {
                "employeeCodeList": [self.userCode]
            }
            friendUserInforesult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(friendUserInforesult.json()['msg'],'操作成功','获取信息失败')
    
        #获取代办任务
        def test8_doinglist(self):
            path = '/api/workflowweb/approve/v1/doing/list'
            data = {
                "pageNum": 1,
                "pageSize": 5,
                "processDefinitionKeys": None
            }
            doinglistresult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(doinglistresult.json()['msg'],'操作成功','获取代办任务失败')
    
        #获取我发起的任务
        def test9_initiatorlist(self):
            path = '/api/workflowweb/approve/v1/initiator/list'
            data = {
                "pageNum": 1,
                "pageSize": 5,
                "instStatus": "approval",
                "processDefinitionKeys": None
            }
            initiatorlistresult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(initiatorlistresult.json()['msg'],'操作成功','获取我发起的任务失败')
    
        # #查询考勤信息
        def test_10_getonemain(self):
            path = '/api/oa/v1/myattendance/getonemain'
            timenow = time.strftime('%Y-%m', time.localtime(time.time()))
            data = {
                "whichMonth": timenow
            }
            # headers = {
            #     'Host': 'workpre.vvtechnology.cn',
            #     'Content-Type': 'application/json;charset=utf-8',
            #     'Accept': 'application/json,text/plain,*/*',
            #     'User-Agent': 'VV%20Work/3097CFNetwork/1197Darwin/20.0.0',
            #     'Connection': 'keep-alive',
            #     'uc': self.userCode,
            #     'Accept-Language': 'zh-cn',
            #     'Authorization': self.token,
            #     'Content-Length': '24',
            #     'Accept-Encoding': 'gzip,deflate,br'
            # }
            getonemainresult = self.baseapi.post(url=self.url+path,data=data,headers=self.headers)
            self.assertEqual(getonemainresult.json()['msg'],'操作成功','查询考勤失败')
    
    
        #薪资单待办消息
        @unittest.skip('接口不通,暂时跳过')
        def test11_unConfirm(self):
            path = '/api/finance/salary/v1/app/unConfirm'
            params = ""
            headers = {
                'Host': 'workpre.vvtechnology.cn',
                'uc': self.userCode,
                'Connection': 'keep-alive',
                'Accept': 'application/json,text/plain,*/*',
                'User-Agent': 'VV%20Work\/3097CFNetwork/1197Darwin/20.0.0',
                'Authorization': self.token,
                'Accept-Language': 'zh-cn',
                'Accept-Encoding': 'gzip,deflate,br'
            }
            unconfirmresult = self.baseapi.get(url=self.url+path,params=params,headers=self.headers)
            print(unconfirmresult.text)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    if __name__ == '__main__':
        unittest.main()
    
    
  • 遇到问题还是要处理的

  • self.url 是全局变量,不知道突然后面为什么都变成 None

  • 你看我这几条也都正常执行

  • 但是我其他几条 case 也都是用的 self.url ,都可以正常

  • 确实是 None,但是我前面的 self.url 都是正常的