Blog on Dan North & Associates Limited 10月02日 20:59
RMonkey自动化测试工具介绍
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

RMonkey是一个增强Ruby接受测试的工具,通过模拟猴子行为来执行探索性测试,提高软件质量。它使用usually、sometimes和rarely关键字来定义不同行为的执行概率,帮助测试人员发现系统在异常使用方式下的潜在问题。该工具适用于Ruby开发者,可与Selenium、Watir等框架结合使用,特别适用于长时间、大规模的 soak 测试场景,帮助团队识别导致系统故障的具体事件序列。

🔍 RMonkey通过增强Ruby接受测试,模拟猴子行为(随机输入和操作)来执行探索性测试,旨在发现常规测试中难以察觉的缺陷,弥补自动化测试仅验证已知功能的不足。

🎲 该工具使用'usually'(通常,默认80%概率)、'sometimes'(有时,默认15%概率)和'rarely'(很少,默认5%概率)三个关键字来定义不同测试步骤的执行概率,允许测试人员自定义这些概率以匹配实际使用场景的随机性。

📊 RMonkey能够记录执行的事件序列,并在测试失败时生成详细的叙事报告,帮助团队追踪和分析导致故障的具体操作路径,这对于定位和修复罕见但关键的bug至关重要。

🔗 该工具可与多种测试框架集成,如Selenium、Watir或通过JRuby驱动的JUnit、MarathonMan、WebDriver等Java测试框架,提高了其在不同技术栈中的适用性和灵活性。

⏳ 特别适用于长时间、大规模的soak测试,通过模拟成千上万的并发用户操作,RMonkey可以帮助团队评估系统在持续压力下的稳定性和可靠性,并精确识别导致系统崩溃的行为模式。

So I was hanging out with a bunch of geeks in Switzerland, having one of those late night conversations, and an idea sort of emerged, and the more I thought about it, the more I liked the idea. And then I was thinking that a) I’m useless at following through on ideas and b) I would love someone to take this forwards. So here it is.

Our premise was that the value of automated testing is in its repeatability and low investment (in terms of human effort). However, running the same tests all the time just verifies that the system does a small number of well-known activities.

The value of exploratory testing, on the other hand, is to try all the weird combinations that people might try—aka monkey testing—in order to break the system by using it in unlikely ways. The problem is that exploratory testing requires people, so it’s slow and expensive.

Cue RMonkey (and possibly PyMonkey and JMonkey). RMonkey augments your Ruby acceptance tests, to emulate monkey behaviour. It works like this:

Boring, old-style test:

def test_user_can_login web.navigate_to '/login' web.enter_value :name, 'bob' web.enter_value :password, 'secret' web.press_button :login assert_that web.current_page, has_title("Welcome")end

Now we monkey it up, with the keywords usually, sometimes and rarely:

require 'rmonkey'include RMonkeydef test_user_can_login navigate_to '/login' usually { web.enter_value :name, 'bob' } sometimes { web.enter_value :name, 'kate' } rarely { web.enter_value :name, random_string() } usually { web.enter_value :password, 'secret' } # sometimes don't bother web.press_button :login sometimes { 10.times { web.press_button :login } } # bored bored bored! assert_that web.current_page, has_title("Welcome")end

So now you have automated monkey tests. There are default probabilities for usually/sometimes/rarely (say 80%, 15%, 5%) but that is customizable:

monkey_see :usually => 75, :sometimes => 22, :rarely => 3

The interesting part, of course, is to know what sequence of events leads to a test failure. A more fully-featured RMonkey would keep track of which events it executed and produce an informative narrative if things turned bad.

In the spirit of the infinite monkeys metaphor, this would prove most useful in a soak-testing scenario, whereby thousands of monkeys were hitting an application over an extended period of time. You would want to know that a) mostly it worked, and b) when it didn’t work, which sequence of events caused it to break.

Some obvious applications for RMonkey would be in driving Selenium or Watir, or using JRuby to drive JUnit, MarathonMan, WebDriver or any of the other Java testing frameworks.

The code for rmonkey.rb is simply:

module RMonkey LIKELIHOOD = { :usually => 80, :sometimes => 15, :rarely => 5 } def usually yield if rand(100) < LIKELIHOOD[:usually] end def sometimes yield if rand(100) < LIKELIHOOD[:sometimes] end def rarely yield if rand(100) < LIKELIHOOD[:rarely] end def monkey_see(likelihood) LIKELIHOOD.merge(likelihood) endend

So anyway, let me know if you would like to get involved in developing RMonkey. I think it’s a really appealing idea and I’d love to see someone do something with it.

Check out

Goalwards®

, our new business agility practice!

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

RMonkey 自动化测试 探索性测试 Ruby Selenium Watir JRuby Soak测试 软件质量
相关文章