简体   繁体   English

同时运行unittest测试用例和机器人框架测试用例

[英]Running unittest Test Cases and Robot Framework Test Cases Together

Our group is evaluating Robot Test Framework for our QA group, not just for BDD, but also to possibly cover a lot of our regular functionality testing needs. 我们小组正在为我们的QA小组评估机器人测试框架,不仅仅针对BDD,还可能涵盖我们的许多常规功能测试需求。 It certainly is a compelling project. 这当然是一个引人注目的项目。

To what extent, if any, is Robot Framework based on xunit (unittest) architecture? 基于xunit(unittest)架构的Robot Framework在多大程度上(如果有的话)? I see that unittest asserts can be used, but I don't see that the RF testcases themselves are based on unittest.TestCase. 我看到可以使用unittest断言,但我没有看到RF测试用例本身是基于unittest.TestCase。

Ideally, our organization would like to be able to be able to write Robot Framework tests, as well as Python unittest testcases, run the testcases together from one runner and get integrated results, reuse RF's Selenium2 Library's "keywords" as functions used by our regular unittest testcases in order to share a common SE code-base. 理想情况下,我们的组织希望能够编写Robot Framework测试,以及Python unittest测试用例,从一个跑步者一起运行测试用例并获得集成结果,重用RF的Selenium2 Library的“关键字”作为我们常规使用的函数unittest测试用例,以共享一个共同的SE代码库。

Is this a solved problem? 这是一个解决的问题吗? Does anybody do this kind of thing? 有人做过这种事吗?

RobotFramework is not the right tool for unit testing. RobotFramework 不是单元测试的正确工具。

  • Unit-tests should be written in the same language of the units (modules, classes, etc.) 单元测试应使用相同语言的单元(模块,类等)编写
  • The ability to describe scenarios in natural language (which is one of the strongest features of systems like RF) is worthless in unit tests. 用自然语言描述场景的能力(这是RF等系统最强大的功能之一)在单元测试中毫无价值。 At this level of testing scenarios are for input x you get output y . 在这个级别的测试场景中输入x得到输出y

RF is best suited in Acceptance Testing and Integration Testing, the top-grained verification of your system. RF最适合验收测试和集成测试,这是您系统的一流验证。

Nevertheless you can integrate RF and xunit in your QA system together. 不过,您可以将RF和xunit集成到QA系统中。 And merge reports from RF and unit-test. 并合并来自RF和单元测试的报告。

While the goals of code unittesting and functional/non-functional testing are worlds apart, the python unittest module can lend itself as a framework for QA testing and unittesting. 虽然代码单元测试和功能/非功能测试的目标是分开的,但python unittest模块可以作为QA测试和单元测试的框架。 Robot framework was designed from the ground up for QA testing with hooks into languages such as Python/Java. 机器人框架是从头开始设计的,用于QA测试,钩子连接到Python / Java等语言。

Robot framework works well for tabular test cases with pretty HTML output. Robot框架适用于具有漂亮HTML输出的表格测试用例。 While unittest does quite well with what it name implies, it can also lend itself well to non-unit tests with asserts calling functional test code directly. 虽然unittest与其名称所暗示的相当不错,但它也可以很好地适用于非单元测试,其中asserts直接调用功能测试代码。 There are plugins for unittest output too such as HTMLTestRunner that have a similar 'pretty' nature of Robot framework html output. 还有用于unittest输出的插件,例如HTMLTestRunner ,它具有类似于Robot的html输出的“漂亮”特性。

We used Robot framework heavily for our QA testing at work, and we decided to switch to all of the test cases to the unittest module. 我们在工作中对QA测试大量使用Robot框架,我们决定将所有测试用例切换到unittest模块。 While I understand it is not the intent of the module to be a functional test bed, Robot framework was proving to be a layer of complication from the test cases we needed to write and execute. 虽然我理解模块不是一个功能测试平台的意图,但机器人框架被证明是我们需要编写和执行的测试用例的一个复杂层。 This was causing more time and effort hooking in the native test code into Robot, with tougher and tougher debugging as the test suite grew. 这导致更多的时间和精力将本机测试代码挂钩到Robot中,随着测试套件的增长,调试越来越强硬。 With unittest, we execute the same tests in native python (Robot's built-in features and plugins were too vanilla for the complexity of our project). 使用unittest,我们在本机python中执行相同的测试(Robot的内置功能和插件对我们项目的复杂性来说过于夸张)。 We now rely on the python language directly with full IDE support during QA test development, then report back with whichever CI tool/reporting mechanism. 我们现在在QA测试开发期间直接依赖python语言和完全IDE支持,然后使用任何CI工具/报告机制进行报告。

Robot is not at all based on xunit technologies. 机器人根本不是基于xunit技术。 Personally I think it makes a great unit testing framework for python code, since you can create keywords that can directly import your modules. 我个人认为它为python代码提供了一个很好的单元测试框架,因为你可以创建可以直接导入模块的关键字。 I use this technique for some projects I work on. 我将这种技术用于我工作的一些项目。

With robot, you can tag your unit tests or put them all in a separate hierarchy so that you can run them separate from acceptance tests if you like, or combine them and get statistics broken out separately. 使用机器人,您可以标记单元测试或将它们全部放在单独的层次结构中,以便您可以根据需要单独执行验收测试,或者将它们组合在一起并单独分析统计信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM