现有 Flash 组件的自动化测试(非 UI) [英] Automated testing (non-UI) for existing Flash component

查看:30
本文介绍了现有 Flash 组件的自动化测试(非 UI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建并维护了一组 Flash 组件,这些组件分发给发布者并允许他们与我们的系统集成.目前该组件没有 UI,仅包含用于查询我们的系统服务器、解析响应和修改查询中发送的参数的编译代码.Flex 和 CS3 都有一个 As2 版本和一个 AS3 版本.我们典型的工作流程是这样的:

I build and maintain a set of Flash components that is distributed to publishers and allows them to integrate with our system. Currently the component has no UI and simply contains compiled code for querying our system servers, parsing the response, and modifying the params sent in the query. There's an As2 version and AS3 versions for both Flex and CS3. Our typical workflow is like this:

1.) 加载组件2.) 在组件上设置参数3.) 告诉组件查询我们的系统4.) 等待一个事件表明响应已被接收并解析5.) 在组件上调用方法来检索和使用解析的数据

1.) load the component 2.) set parameters on the component 3.) tell the component to query our system 4.) wait for an event saying the response has been received and parsed 5.) call methods on the component for retrieving and using parsed data

我们最近一直在谈论自动化这些组件的测试,似乎有很多关于 AsUnit 和 FlexUnit 等框架的讨论.但是,我一直无法掌握如何有效地使用其中之一.示例和教程总是忽略现实世界的示例,而是提供多个类和过多的代码来测试示例函数是否返回 num1+num2.

We've been talking a lot lately about automating the testing of these components, and there seems to be a lot of buzz around frameworks like AsUnit and FlexUnit. However, I've never been able to grasp how I might effectively use of one of these. The examples and tutorials always skimp on real-world examples and instead provide multiple classes and excessive code for testing whether an example function returns num1+num2.

我唯一能猜到的是,这些测试框架旨在从一开始就实施,并在开发之初就内置了测试套件、测试运行程序和测试用例的规划.

The only thing I can guess is that these testing frameworks are intended to be implemented from the start, with planning for the test suite, test runner, and test cases built in at the start of development.

我们的组件的自动化测试必须确保属性设置正确,这些属性在请求中发送到我们的系统,收到的响应考虑到发送的参数是正确的,解析的数据包含正确的信息,并且没有错误、错误的响应或无限的解析循环.

An automated test of our component would have to make sure properties were properly set, those properties were sent in the request to our system, the response received was correct considering the parameters sent, the parsed data includes correct information, and no errors, bad responses, or infinite parsing loops are caused.

我的问题是,是否有任何方法可以自动测试现有的、广泛分布的、已建立的 Flash 组件,而无需完全重新设计以适应测试框架?还是我误解了测试框架而这已经成为可能?

my question is, is there any way to automate testing of an existing, widely distributed, established Flash component without completely reworking it to fit into a testing framework? Or am I misunderstanding the test frameworks and this is already possible?

更新:感谢您的回复.我已经开始将我的组件与 AsUnit 集成,并认为我对它如何帮助我有了很好的理解.但是,AS2 AsUnit 不支持异步测试用例,我很难找到支持的 AS2 单元测试框架.异步测试对这个项目非常重要.有人对不同的框架有任何建议吗?谢谢!

UPDATE: Thanks for the responses. I have started to integrate my component with AsUnit and think I have a pretty good understanding of how it can help me. However, the AS2 AsUnit does not support asynchronous test cases, and I'm having a hard time finding an AS2 unit test framework that does. Asynchronous testing is REALLY important to this project. Does anyone have any recommendations for a different framework? Thanks!

推荐答案

我们在我们的项目中使用了 FlexUnit,我对此非常满意.假设您的项目设计为具有相当松散的耦合度,那么您根本不需要进行太多更改(如果有的话)来测试您的代码.如果您已经在使用 MVC 框架,例如 CairngormPureMVC,FlexUnit 应该非常轻松地集成.

We're using FlexUnit on our project and I'm pretty happy with it. Assuming your project was designed with a fairly loose degree of coupling, you shouldn't need to change much at all (if anything) in order to test your code. If you're already using an MVC framework like Cairngorm or PureMVC, FlexUnit should integrate pretty painlessly.

不过,我要说的是,我在 Flash/Flex 单元测试方面的经验并不像在其他语言(如 Ruby 或 .NET)方面那样积极,原因有以下三个.首先,如此高度的动作脚本代码与 UI 相关,而且这种代码即使不是不可能测试也很难.另一个原因是测试运行器不适合插入到持续集成环境中,例如 CruiseControl.NETCruiseControl.rb 因为它需要一个人来运行它并单击按钮.最后,单元测试的一个巨大好处通常是您可以将它与覆盖分析工具一起运行,例如 NCoverrcov.如果没有经过修改的编译器(例如 Flexcover.

I will say however that my experience with Flash/Flex unit testing is not nearly as positive as it has been with other languages such as Ruby or .NET for three reasons. First being that such a high degree of actionscript code is UI related, and this sort of code is difficult if not impossible to test. Another reason is that the test runner doesn't lend itself well to being plugged into a continuous integration environment such as CruiseControl.NET or CruiseControl.rb since it requires a human to run it and click buttons. Lastly, a huge benefit of unit testing is usually that you can run it alongside a coverage analysis tool such as NCover or rcov. Flash/Flex doesn't lend itself to this sort of analysis with out a modified compiler such as Flexcover.

这篇关于现有 Flash 组件的自动化测试(非 UI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆