使用机器人框架进行 ATDD

发布于 2024-09-02 06:07:18 字数 138 浏览 6 评论 0原文

我想听听其他人使用 Robot Framework 进行自动化验收测试的经验。

它的主要优点和缺点是什么以及与其他框架(主要是 Fitnesse 和 Selenium)的比较?

将测试的代码是实时的遗留代码,主要是 C++ 语言。

I would like to hear other people's experience with Robot Framework for automated acceptance testing.

What are its major strengths and weaknesses as well as any comparison with other frameworks (mainly Fitnesse and Selenium)?

The code that will be tested is real-time, legacy code, mainly in C++.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝咒 2024-09-09 06:07:18

在我撰写本文时,我已经在三个不同的公司使用了 Robot Framework,时间跨度约为六年,并且都以某种方式取得了成功。

我的经历

公司 1

我第一次使用 Robot 是一家顶级互联网旅游公司的基于 Java 的 Web 应用程序。我们将 Robot 与 Jython 结合使用,这让我们可以在 Java 中创建关键字并直接与测试中的系统进行操作。我们使用 Selenium 来驱动 Web 浏览器,大部分测试都是在 Firefox 上进行的。虽然 QA 组织的测试工作在很大程度上取得了成功,但开发组织却未能接受它——他们更喜欢使用 JUnit 而不是 Robot。

公司 2

我认为我的第二家公司非常成功。我们以多种方式使用机器人。主要用途是驱动 Internet Explorer 对非常成功的商业 .NET Web 应用程序进行验收和回归测试。

我们还使用它通过将 Selenium 与 Appium 相结合来测试 iPad 应用程序。我们使用 Robot 来测试向应用程序提供数据的 RESTful 服务。我们编写了专门的关键字来进行图像分析,并且我们还使用机器人测试在每次训练之前对我们的训练设备进行快速分析。我们有关键字让我们在测试前对数据库进行快照,并在测试后恢复数据库。

我们还开始使用 Robot 来帮助进行手动测试。我们将手动测试用例放入 Robot 中,这使我们能够利用 Robot 的报告和标记功能。当这些测试运行时,它们会提示用户执行手动步骤,事实证明,这比让测试人员从测试用例管理工具或 Word 文档中读取手动步骤要高效得多。

公司 3

第三家公司是一家大公司(收入为 10 亿美元),拥有相当多的 IT 员工。他们的测试人员的技术水平非常(我记得有一个人不知道命令行是什么)。我们有一个团队致力于编写一组核心关键词,并为其他团队提供培训和指导。我认为机器人的使用有助于让技能最低的测试人员发挥一些作用,尽管即使使用高级关键字,他们也很困难。

公司 4

最近我搬到了一家非常小的公司,只有少数开发人员,没有专门的测试人员。我们支持在 Robot 中使用页面对象框架,我们现在拥有一套异常稳定、易于阅读的高级验收测试。该公司对机器人的使用取得了巨大的成功。

优点

机器人的最大优点是它的灵活性。我们使用 Robot 来支持手动测试、SOAP 和 REST 服务测试、基于 Web 的 UI 测试、数据库测试、图像测试以及移动应用程序测试。因为 Robot 很容易通过额外的库进行扩展,所以如果您愿意卷起袖子写一些关键字,几乎没有什么是您无法测试的。根据您的设置,您可以通过 Robot 远程 API 用 Python、Java、.NET 或任何语言编写关键字。

由于机器人测试用例和关键字是用纯文本编写的,因此您不必局限于使用专有工具来创建或查看测试。用户可以选择自己喜欢的工具——Visual Studio、Eclipse、Emacs、记事本等。还有一个机器人专用的 IDE (RIDE),尽管我不推荐它。此外,因为这些文件是纯文本,所以它们与其他软件工具集成得很好——它们很容易区分、合并、搜索等。

缺点

Robot 使得编写低质量的测试变得很容易。虽然有一些工具可以记录关键字和测试用例,并为关键字、测试用例和变量使用人类可读的名称,但没有好的方法来强制实施最佳实践。编写大量测试和关键字需要纪律。俗话说,机器人给了你足够的绳索来吊死自己。

另一个弱点是 Robot 的进展速度相当缓慢。从好的方面来说,Robot 很强大并且相对没有错误,因此不需要频繁打补丁。然而,有些功能请求在问题跟踪器中多年来一直没有任何进展,这可能令人沮丧。

总结

在所有公司中,我们都喜欢能够利用 Robot 语法提供的灵活性来创建数据驱动测试、BDD 样式测试以及简单的过程测试。在所有情况下,由于测试都是纯文本文件,因此可以使用我们的 SCM 工具(Mercurial、Subversion 和 Git)轻松管理测试资产。

对我来说,Robot 已被证明易于使用、极其易于扩展,并且适用于各种测试任务,从 Python 函数的单元测试,到 Web 服务测试、基于浏览器和平板电脑的 UI 测试、图像测试、数据库测试,甚至可以提高手动测试的效率。

I have used Robot Framework at three different companies spanning about six years at the time that I write this, and all have been successful in one way or another.

My experiences

Company 1

The first place I used Robot was a Java-based web application for a top-tier Internet travel company. We used Robot with Jython, which let us create keywords in Java and directly act with the system under test. We used Selenium to drive the web browser, with most of our testing being on Firefox. While the testing effort was largely successful with the QA organization, the development organization failed to embrace it -- they preferred to use JUnit rather than Robot.

Company 2

My second company I feel was an unqualified success. We used Robot in a multitude of ways. The primary use was to drive Internet Explorer for acceptance and regression testing of a highly successful commercial .NET web application.

We also used it to test an iPad app by combining Selenium with Appium. We used Robot to test the RESTful services that supplied data to the app. We wrote specialized keywords that let us do image analysis, and we also used Robot tests to do quick analysis of our training equipment before each training session. We had keywords that let us snapshot a database before a test, and to restore the database after a test.

We also started using Robot to help with manual testing. We put manual test cases in Robot, which let us leverage Robot's reporting and tagging features. When these tests would run, they would prompt the user to perform manual steps which was proven to be much more efficient than when we had testers reading manual steps out of a test case management tool or Word document.

Company 3

The third company was a large company ($1B revenue) with a fairly large IT staff. They had testers with very low technical skill (I remember one who had no idea what a command line was). We had one team dedicated to writing a core set of keywords, and to providing training and mentoring to the other teams. I think the use of Robot was instrumental in getting some use out of the least-skilled testers, though even with high level keywords it was a struggle with them.

Company 4

Most recently I moved to a very small company with just a handful of developers and no dedicated testers. We embraced the use of page objects with Robot Framework, and we now have an exceptionally stable suite of easily readable high level acceptance tests. The use of Robot at this company has been an unqualified success.

Strengths

The biggest strength of Robot is its flexibility. We've used Robot to support manual testing, testing of SOAP and REST services, web-based UI testing, database testing, testing of images, and the testing of mobile apps. Because Robot is so easy to extend with additional libraries, there's almost nothing you can't test if you're willing to roll up your sleeves and write some keywords. Depending on your setup, you can write keywords in Python, Java, .NET, or really just about any language through the Robot remote API.

Because Robot test cases and keywords are written in plain text, you're not locked in to using a proprietary tool to create or view tests. Users are able to pick the tool of their choice -- Visual Studio, Eclipse, Emacs, Notepad, etc. There is also a Robot-specific IDE (RIDE), though I don't recommend it. Also, because the files are plain text, they integrate well with other software tools -- they are easy to diff and merge, to search, etc.

Weaknesses

Robot makes it easy to write low-quality tests. While there are facilities to document keywords and test cases, and to use human-readable names for keywords, test cases and variables, there's no good way to enforce best practices. Writing a large body of tests and keywords requires discipline. As the saying goes, Robot gives you plenty of rope to hang yourself with.

Another weakness is that the pace of progress on Robot is fairly slow. On the plus side, Robot is robust and relatively bug free, so there's not a big need for frequent patches. However, there are feature requests that languish in their issue tracker for years with no movement, which can be discouraging.

Summary

In all companies we've enjoyed being able to leverage the flexibility provided by Robot's syntax to create data-driven tests, BDD-style tests, as well as simple procedural tests. And in all cases, because the tests are plain text files, the test assets were easy to manage with our SCM tools (Mercurial, Subversion, and Git)

For me, Robot has proven to be easy to use, extremely easy to extend, and useful for a wide range of testing duties, from unit-testing of Python functions, to testing of web services, browser-based and tablet UI testing, the testing of images, the testing of databases, and even to improve the efficiency of manual testing.

耶耶耶 2024-09-09 06:07:18

我们在我的工作场所使用 Robot Framework 已经有一年多了,目前已经取得了一定的成功。和海报一样,我们也做C++的工作。我们花了一些时间来评估 Robot 与 Fitnesse/Slim,当时,两种解决方案都很好,但决定因素是(截至 2009 年):

  • Robot 及其报告如何扩展到大型项目
  • 更清楚的是 如何对 Fitnesse 工件进行版本控制并不明显

从技术角度来看,我们一直在使用 SWIG 在 Robot 和 C++ 之间架起桥梁。我们将测试装置包装在 SWIG 中,并将其与测试中的生产代码链接起来 - 为我们提供了一个可以由 Robot 导入的 python 模块。

我们几乎完全使用 .txt 格式进行机器人输入 - 我们发现这个版本控制得更好,更容易阅读,而且我们根本没有使用 HTML 的高级功能(这就是我们开始的地方)。此外,我们正在使用“BDD 样式” 机器人语法也是如此。我们使用 GoogleMock 和一些包装器来帮助我们设定期望,这些期望在每个机器人测试的拆卸过程中进行检查。

就组织测试而言,我们决定采用以下方法(灵感来自此处给出的 Dale Emery 方法):

  • 主要功能层次结构由文件夹结构表示。
  • 机器人测试文件名中描述了功能大小的东西。
  • 机器人测试用例名称中使用了该功能每个部分的描述。
  • 给出了一个示例作为测试用例中的步骤。
  • 示例文本使用 Robot“关键字”分解为多个步骤。
  • 测试夹具驱动生产代码。

例如,手机可能有这样的东西:

//  PhoneProject/MakingCalls/DialAPhoneNumber.txt

*** Test Case ***
A user can dial a US number with an area code, up to 10 digits
   Given a phone without any numbers dialed
   Expect the attempted phone number to be 123-456-7890
   When a user enters the numbers 1234567890


// A separate MakingCallsKeywords.txt or something similar
*** Keyword ***
Given a phone without any numbers dialed                CreateNewDialer
Expect the attempted phone number to be ${phoneNumber}  ExpectDialedNumber  ${phoneNumber}
When a user enters the numbers ${numbersEntered}        DialNumbers ${numbersEntered}

// MakingCallsFixture.cpp  (which gets wrapped by SWIG)

std::wstring MakingCallsFixture::DialNumbers(const std::wstring& numbersEntered)
{
   ... Drive production code ...
}

// CreateNewDialer, ExpectDialedNumber also go here

然后我们会将其与涵盖角落条件的单元测试配对(例如,确保允许不超过 10 位数字) - 或者这可能是另一个验收测试(可执行规范),具体取决于关于谁在阅读测试以及他们对该领域的熟悉程度。

我们创建这些规范的草案,并在开始工作之前与领域专家和团队进行审查。这有助于消除早期的一些误解。

We have been using Robot Framework at my place of work for several over a year now with moderate success. Like the poster, we also do C++ work. We took some time to evaluate Robot against Fitnesse/Slim and, at the time, both solutions were good, but the deciding factors were (as of ~2009):

  • It was clearer how Robot and its reports would scale to large projects
  • It wasn't obvious how to version control Fitnesse artifacts

From a technical perspective, we have been using SWIG to bridge between Robot and C++. We wrap our test fixtures in SWIG and link it with the production code under test - giving us a python module that can be imported by Robot.

We use the .txt format for Robot input almost exclusively - we've found that this version controls better, it's easier to read, and we simply weren't using the advanced features of HTML (which is where we started). In addition, we are using the "BDD Style" Robot syntax as well. We use GoogleMock with some wrappers to help us set expectations which are checked during the teardown of each Robot test.

As far as organizing the tests, we have settled on the following approach (with inspiration from Dale Emery's approach given here):

  • Major functional hierarchy is represented by a folder structure.
  • A feature-ish sized thing is described in a Robot test file name.
  • A description of each part of that feature is used at the Robot test case name.
  • An example is given as the steps in the test case.
  • The example text is broken down into steps using Robot "keywords".
  • The test fixture drives the production code.

For example, a phone might have something like this:

//  PhoneProject/MakingCalls/DialAPhoneNumber.txt

*** Test Case ***
A user can dial a US number with an area code, up to 10 digits
   Given a phone without any numbers dialed
   Expect the attempted phone number to be 123-456-7890
   When a user enters the numbers 1234567890


// A separate MakingCallsKeywords.txt or something similar
*** Keyword ***
Given a phone without any numbers dialed                CreateNewDialer
Expect the attempted phone number to be ${phoneNumber}  ExpectDialedNumber  ${phoneNumber}
When a user enters the numbers ${numbersEntered}        DialNumbers ${numbersEntered}

// MakingCallsFixture.cpp  (which gets wrapped by SWIG)

std::wstring MakingCallsFixture::DialNumbers(const std::wstring& numbersEntered)
{
   ... Drive production code ...
}

// CreateNewDialer, ExpectDialedNumber also go here

We would then pair this up with unit tests that cover the corner conditions (e.g. ensure no more than 10 digits are allowed) - or maybe that would be another acceptance test (executable spec) depending on who is reading the tests and their familiarity with the domain.

We create a draft of these specs and review with domain experts and the team prior to beginning work. This has helped flush out a number of misunderstandings early on.

缺⑴份安定 2024-09-09 06:07:18

我将 Robot 框架用于以下场景。

UI 测试

  1. Robot 框架非常适合测试用户界面。
  2. 该框架附带 RIDE 编辑器,可用于编写测试用例。
  3. 您不必是 Selenium 和 Selenium 命令方面的专家
    可在 RIDE 编辑器中搜索。
  4. 您可以通过使用关键字和共享来共享代码
    资源。它允许您简单地重用测试用例并进行测试
    库代码。
  5. 您可以轻松调用Python库函数来完成更繁琐的任务。

对于服务测试,我发现 Robot 框架对于我正在进行的测试自动化有点难以使用。

我们的应用服务层完全是用C/C++编写的。我个人在 Windows 笔记本电脑上工作,我们的应用程序驻留在 Linux 服务器上。

我发现 *Fitnesse 框架** 更有用且更容易实现自动化。 Fitnesse 具有下面提到的额外功能,可以轻松编写测试用例。我在Robot中找不到类似的功能。

决策表 - 您可以以 Microsoft .xls 类型的格式编写测试用例。数据网格中的每一行都代表一个测试用例。每行都有一组输入和输出。标题中的输出前面将带有问号。

查询表 - 测试的输出将是您想要验证的数据列表。

Fitnesse 还允许与 C 等其他语言轻松集成(使用 Slim Service)。这不需要任何集成编码。 Fitnesse 测试用例直接执行测试装置、getter 和 setter。

我的经验总结:

  • 我找到了一个易于使用的 UI 自动化工具。

  • 我发现它有点难以用于服务自动化。

I used Robot framework for following scenarios.

UI testing

  1. The Robot framework is really good for testing user interface
  2. The framework comes with the RIDE editor which can be used for writing test cases.
  3. You do not have to be an expert on Selenium and Selenium commands
    are searchable in the RIDE editor.
  4. You can have shared code by using keywords and shared
    resources. It allows you to simply reuse test cases and test
    library code.
  5. You can call easily call a Python library function to do more tedious tasks.

For service testing, I found the Robot framework a little difficult to use for the kind of test automation I was undertaking.

Our application service layer is completely written in C/C++ . I personally work on a Windows laptop and our application resides on a Linux server.

I found the *Fitnesse framework** much more helpful and simpler to do automation with. Fitnesse had the below mentioned extra features which allowed to write test cases easily. I could not find similar features in Robot.

Decision table - You can write test cases in Microsoft .xls kind of format. Each row in the data grid will represent a test case. Each row will have a set of inputs and outputs. Outputs will be preceded by question mark in the header.

Query Table - Output of test will be list of data which you would want to validate.

Also Fitnesse allows easy integration with other languages like C (using Slim Service). This does not require any integration coding. Fitnesse test cases directly execute test fixtures, getters, and setters.

Summary of my experience:

  • I found an easy-to-use tool for UI automation.

  • I found it a little difficult to use for service automation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文