tag 标签: Robot

相关博文
  • 热度 6
    2022-7-15 17:31
    1726 次阅读|
    0 个评论
    前言 汽车电子软件扮演着越来越重要的角色,为适应市场变化,车载软件和功能的开发需要快速迭代。 敏捷开发、持续测试、CI/CT/CD实现和DevOps等成了汽车电子行业的高频词,也正在帮助OEM和零部件供应商实现频繁的代码部署和实现可靠软件交付的目标。测试自动化是这些过程中不可或缺的一部分,因为可以提升测试效率以加速开发迭代,特别是对于重复性的任务或不需要任何人工干预的任务。 说到自动化测试,Robot Framework作为自动化测试领域的明星框架,已经开始摩拳擦掌,跃跃欲试。今天我们一起来看下Robot Framework在汽车电子测试中,可以发挥出多大的作用。 1 、Robot Framework简介 Robot Framework 是一个广受欢迎的自动化测试框架。所谓框架,可以理解为一组准则,遵循这些准则可以获取明显的收益。自动化测试框架就是 由一个或多个自动化测试基础模块、自动化测试管理模块、自动化测试统计模块等组成的工具集合。 Robot Framework 是一个基于Python语言开发的,可扩展的,是以关键字驱动模式的自动化测试框架。它具有以下特点: (1)编辑用例简单,启用易于使用的表格语法,以统一的方式创建测试用例; (2)提供从现有关键字创建可重复使用的更高级别关键字的功能; (3)提供易于阅读的结果报告和HTML格式的日志; (4)提供一个简单的库API,用于创建自定义测试库,可以使用Python或Java本机实现; (5)支持创建数据驱动的测试用例; (6)提供标记以分类和选择要执行的测试用例; (7)可以和SVN或者GIT及Jenkins持续集成。 上文我们提到Robot Framework是以关键字驱动模式的自动化测试框架,同时支持创建数据驱动的测试用例。那么关键字驱动和数据驱动分别有什么特点呢? 关键字驱动是由关键字和数据组成测试用例执行测试,测试框架的底层负责解释关键字,完成指令,测试用例的编辑者只需要使用关键字和数据组合,即可实现复杂的测试逻辑。测试执行的代码和测试用例代码是分离的。这种方式学习成本比较高,开发关键字及其相关功能的初始投资可能需要更长的时间。 数据驱动测试是从数据文件读取输入、输出数据,通过变量传入测试脚本执行测试,数据是可变的,测试设计是重复的、高度抽象的。使用这种测试方式可以减少重复劳动,测试用例易于修改和维护。但是这种方式不擅长逻辑处理,一组脚本只能处理特定格式的数据。在一些特定的测试场景下,这种方式具有明显优势。比如汽车ECU(如网关)测试有数据转发/路由的测试场景,需要测试的数据有时多达上千个,我们只需创建一条数据转发业务的测试用例,从数据文件中读取输入、输出数据后,遍历所有数据即可完成测试。 2 、Robot Framework整体架构 Robot Framework 是一个通用的,和具体测试工具松耦合的框架,其高度模块化的架构如下图所示: 测试数据( Test Data ) 使用非常简单、易于编辑的表格格式。Robot Framework会解析测试数据, 执行测试用例 , 并生成日志和报告。框架本身对测试对象可以完全“一无所知”, 而是通过 测试库 与其交互。测试库可能是直接使用被测应用程序的接口, 也可以使用其它底层的测试工具作为驱动。 3 、Robot Framework环境安装 Robot Framework 环境的安装比较简单,只需两步即可完成: (1)安装Python配置环境变量; (2)打开dos窗口,输入指令 pip install robotframework,点击回车,安装Robot Framework。 4 、Robot Framework常用关键字 上文我们提到Robot Framework是一个关键字模式驱动的自动化测试框架,Robot Framework的测试用例由关键字和测试数据组成。关键字是用Python语言编写的函数,也即是一个个方法。它是为了完成一个功能来设计的,分为系统关键字和用户关键字。 系统关键字包含标准库里面的关键字和第三方库里面的关键字,就像C/C++的库函数或者Python的内置函数一样。 用户关键字是根据业务需求将不同的业务封装成一个关键字或者将用例执行的步骤封装成一个关键字,就像C/C++或者Python中的用户自定义函数。 下面我们介绍几个常见关键字的用途。 Convert To Integer :将给定的变量转换成一个整数。示例: Import Library :导入扩展库或者自定义库。示例: Get Variable Value :获取变量的值,赋给一个新的变量,如果变量不存在可以设置一个默认值。示例: Log :使用给定的级别记录给定的信息。示例: Set Variable :给变量设置值。示例: Should Be Equal :Robot Framework中的断言关键字,如果给定的对象不相等,就会判定失败。示例: Sleep :测试执行等待一定时间。示例: 5 、Robot Framework测试用例示例 说了这么多,大家肯定想赶紧看看Robot Framework是怎么使用的,现在我们通过一个简单的例子来说明Robot Framework是怎么执行测试的。 这条测试用例的操作步骤如下: (1)加载CANoe测试工程; (2)启动测试; (3)等待一定时间,确保CANoe启动完成; (4)设置系统变量的值; (5)等待一定时间,确保系统变量设置完成; (6)获取关联系统变量的信号值; (7)比较设置的值和读取的值是否相同; (8)终端输出提示“测试用例执行结束”。 Robot Framework 编写的测试用例如下图一所示: 图一Robot Framework测试用例示例 执行测试用例:dos窗口中输入robot 测试用例路径,点击回车即可,这里执行用例的逻辑是使用pip安装Robot Framework时,会在Python安装路径下面的Scripts文件夹生成robot.exe文件,Scripts文件夹已经添加到系统路径,因此不需要再配置robot.exe的系统路径就可以直接调用。 执行后用例后,CANoe中关联系统变量的信号值设置成功,如图二所示。 图二CANoe信号EngineState::OnOff值设置为1 用例执行完成后,生成的测试报告如图三所示。 图三测试用例执行后生成的测试报告 6 、Robot Framework与CANoe结合使用 相比于IT行业的软件测试,汽车电子需要搭建硬件测试环境,测试时需要监控和仿真很多总线信号和硬线信号,CANoe作为专业的总线网络开发和测试工具被众多整车厂和供应商的系统设计师、开发工程师和测试工程师所广泛使用。配合Vector的硬件设备,如VN通信硬件接口卡及VT IO板卡,以及图形化自动化测试工程开发软件vTESTstudio,可以胜任汽车电子研发测试的各项任务。Robot Framework和CANoe结合使用,既带来了Robot Framework可以自动部署测试软件、自动截取日志、可以生成易于阅读的测试报告和可以灵活的选取测试用例的优点,也保留了Vector工具在多总线支持、网络监测和分析、系统仿真等方面的优势,各取所长。 CANoe 是留有COM Interface的,这样我们可以通过第三方的程序调用CANoe开放的API。调用交互的部分DEMO代码如下图四所示: 图四Python编程调用CANoe代码 Robot Framework 和CANoe结合使用一般有两个思路: 第一种情况是把测试用例的过程主体在Robot Framework环境中编写脚本实现并执行,在执行过程中调用CANoe提供测试数据、参数、变量的读取和设定,这个思路适合对时间要求不敏感的测试用例。如下图五所示用例,CanoeHandle为自定义的关键字库,创建了加载CANoe工程、启动测试、停止测试、获取信号值、设置系统变量值、获取系统变量值等关键字,可以使用这些关键字组合创建Robot Framework测试用例,执行测试。 图五基于Robot Framework编写CANoe测试用例 第二种情况是测试用例整体在Vector工具链中开发测试工程和脚本(比如基于vTESTstudio开发图形化测试工程或是CANoe-CAPL编写测试脚本),并在CANoe中执行工程和脚本。此时,如图六所示,Robot Framework作为一个测试用例管理框架来使用,CanoeHandle为自定义的关键字库,创建了加载CANoe工程、加载测试脚本、执行测试脚本等关键字,可以使用Robot Framework进行测试管理,根据实际需求删选测试用例、自动控制测试开始、停止等。结合Jenkins打造通用的自动化持续集成测试平台,可以显著提升测试效率。 图六基于Robot Framework管理CANoe测试工程 结束语 IT 领域的开发理念和以太网等具体通信技术经过优化改造后在汽车上的应用,为软件定义汽车的实现提供了诸多方法论和技术手段上的支撑和支持。同样,发源于IT行业的测试技术也越来越多地被应用到汽车电子的测试中,在过去一年的项目中,北汇已经将RobotFramework与CANoe等汽车行业的主流工具进行了结合应用,积累了一些实践经验,期待与大家深入交流和探讨。下期我们将带来Robot Framework结合Jenkins的测试实践应用的主题,敬请关注。
  • 热度 21
    2016-3-14 18:44
    1307 次阅读|
    0 个评论
    Well, I just saw something that sent shivers down my spine. I don’t know whether to be excited or afraid. My chum Arthur Smith -- a man who manages to balance beekeeping with being a world authority on cosmic rays -- just emailed me with a link to this video from the folks at Boston Dynamics (which was acquired by Google back in 2013).   Here we see the latest and greatest version of the Atlas humanoid robot, which is designed to operate both inside buildings and outdoors and is specialized for mobile manipulation. Standing at 5' 9" tall and weighing in at 180 lbs (which is a lot less than yours truly, let me tell you), Atlas uses state-of-the art sensors to balance itself and to detect and avoid obstacles.   And people wonder why I never go anywhere these days without my trusty Aluminum Foil Deflector Beanie (AFDB) . In addition to protecting against electromagnetic and psychotronic attack -- while also shielding its wearer from brain-scanning and mind-reading activities -- I like to believe that AFDBs will confuse the socks off our future robot overlords.   What? You don’t believe me? Well, we'll see who is laughing when you hear the metallic stomping approaching outside your office door. Meanwhile, I'll be sporting an AFDB complemented by a cool Hawaiian shirt.
  • 热度 24
    2015-8-29 23:11
    1574 次阅读|
    0 个评论
    All sorts of things are currently buzzing in my head. For example, I recently ran across this video showing some awesome robots.   I've seen some of these little scamps before, but others were completely new to me. Even the robots with which I'm familiar are displaying ever-more sophisticated capabilities, such as Honda's humanoid ASIMO robot, which we see literally jumping around. There's even one for my chum David Ashton from Down Under -- a robot kangaroo called FESTO.   I also ran across a series of videos by a guy who refers to himself as "Thoughty 2 ," which is a pretty clever name on multiple levels when you come to think about it. Take this video , for example, which features some bizarre human traditions.   Some of these are funny; some are interesting; some are strange; and some make one's eyes water in sympathy. I don’t know what our future robot overlords are going to make of these when they see them, but I fear it bodes ill for us.   Last, but certainly not least, do you recall this video of a guy riding a monowheel at the Burning Man festival? I have to admit that when I first saw this little beauty (the monowheel, not the guy riding it), I thought to myself "Oooh, Daddy's got to get himself one of those!" (Or words to that effect).   Of course, monowheels come in all shapes and sizes. I also like those rinky-dinky miniature personal transporter versions. In fact I saw someone scooting around on something like this a few weeks ago in Silicon Valley when I was attending ESC, and I have to admit that I experienced an "Oooh, Shiny!" moment.     And then, just this morning, someone pointed me at this column on MakeZine.com, which introduced me to the concept of a monowheel that you sit inside. The image below shows Dr. Dave Southall sitting on (or in, I suppose) one of his creations.     From the expression on Dave's face, I fear he's wishing he'd made the seat a tad more comfortable -- either that or his underwear is riding up -- but the overall concept looks sound. I can easily imagine myself tootling around my neighborhood on one of these little beauties, but I don’t have the time to make one -- I wonder if you can buy them ready built?
  • 热度 17
    2014-4-14 20:18
    1277 次阅读|
    0 个评论
    Festo seems to be on the way to building the robot version of Noah's Ark. The series of bio-inspired robots that have come out of their labs is simply breathtaking. Their latest release is a Kangaroo bot that touts a very energy-efficient jump.   Festo is a company that specialises in pneumatics. Many of their bots are displays of unique pneumatic implementations and control schemes, often pushing the boundaries of what people typically perceive as the best use of pneumatic systems. This Kangaroo is an impressive display of mechanical engineering as well as pneumatic energy harvesting. As the bot jumps, it expends energy, but the landing recaptures some for the next jump. There were actually two designs of this bot: one with an onboard compressor and one with only a high-capacity air reservoir.   The entire bot isn't pneumatic though. The weight distribution in the hips is controlled by electric motors, as you can see in the video. You may also notice that the control scheme is fairly unique. The robot is controlled via a wireless arm-band worn by the operator. Unfortunately, there are no details on how the gesture control system works. Caleb Kraft, Chief Community Editor, EE Times
  • 热度 21
    2014-4-14 20:17
    1626 次阅读|
    0 个评论
    Festo may well be on the track to building the robot version of Noah's Ark. The series of bio-inspired robots that have come out of their labs is simply breathtaking. Their latest release is a Kangaroo bot that touts a very energy-efficient jump.   Festo is a company that specialises in pneumatics. Many of their bots are displays of unique pneumatic implementations and control schemes, often pushing the boundaries of what people typically perceive as the best use of pneumatic systems. This Kangaroo is an impressive display of mechanical engineering as well as pneumatic energy harvesting. As the bot jumps, it expends energy, but the landing recaptures some for the next jump. There were actually two designs of this bot: one with an onboard compressor and one with only a high-capacity air reservoir.   The entire bot isn't pneumatic though. The weight distribution in the hips is controlled by electric motors, as you can see in the video. You may also notice that the control scheme is fairly unique. The robot is controlled via a wireless arm-band worn by the operator. Unfortunately, there are no details on how the gesture control system works. Caleb Kraft, Chief Community Editor, EE Times  
相关资源