单元测试AS3 code为Flash [英] Unit Testing AS3 Code for Flash

查看:272
本文介绍了单元测试AS3 code为Flash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过编写单元测试我的ActionScript 3 code为Flash项目我的工作,以提高我的code,但我有一个心理障碍理解如何处理它的背景下,的闪存程序。我似乎无法总结我的头,围绕如何处理事情诸如addChild和舞台,以及所有的异步处理的典型的Flash应用程序(addEventListeners等待的东西加载等)。它比任何其他语言真的有什么不同?如何开发处理一个Flash程序的特殊环境?

I'm trying to improve my code by writing unit tests for my ActionScript 3 code for Flash projects I work on, but I'm having a mental hurdle understanding how to deal with it in the context of a Flash program. I can't seem to wrap my head around how to deal with things like addChild and the stage, as well as all the asynchronous processing typical of Flash applications (addEventListeners for waiting for things to load, etc.). Is it really any different than any other language? How does a developer deal with the unique environment of a Flash program?

一些说明:

  • 这有什么做用Flex,没有Flex是参与的。
  • 程序只涉及AS3 code文件和包含的资产的FLA。

推荐答案

大问题。这是挑选哪些部分项目的测试挑战 - 类,或两者一个类或集合。

Great question. It's a challenge to pick what parts of a project to test - a single class or collection of classes, or both.

尽管围绕用户界面测试测试可以捕捉许多的逻辑和事件错误,用户界面​​是普遍,其中很多奇怪的事情都可能发生。在Flash的项目很多错误可能是由于意想不到的用户交互模式 - 基本上是一个beta测试者做的东西你永远不会想到要干的UI。

Although testing around the user interface testing can catch many logic and event errors, the UI is commonly where plenty of strange things can happen. Many errors in a Flash project can be due to unexpected user interaction modes - basically a beta tester does something in the UI you never would have thought of doing.

如果你的项目是由用户交互,尤其是游戏为导向,而不是RIA为导向,规划测试一套好的顺序驱动是为测试本身一样重要。例如,您可以尝试的动作A,然后采取B,知道B依赖于A,因为这就是你写的。测试人员可能会尝试B A之前,一个场景,你可能没有预期的之一,如果A和B独立测试为单位,不会被抓住。这可能也意味着你会想要写3或4的测试:A,B,A-> B和B-> A,所以状态数可能失控的

If your project is driven by user interaction, especially game oriented as opposed to RIA-oriented, planning a good set sequence of tests is as important as the tests themselves. For example, you may try action A, then action B, knowing that B depends on A because that's how you wrote it. A tester may try B before A, a scenario you may not have expected and one that would not be caught if A and B were tested independently as units. It may also mean you would want to write 3 or 4 tests: A, B, A->B, and B->A, so the number of states can get out of hand.

要考虑的事情是一个测试框架,比如的FlexUnit 以自动化许多任务。一个很好的出发点上的FlexUnit和测试驱动开发教程,可以<一href="http://webcache.googleusercontent.com/search?q=cache%3ayEreW0_yUf4J%3aelromdesign.com/blog/2010/03/10/test-driven-development-tdd-with-flexunit-4-complete-tutorial/+using+flex+unit+tutorial&cd=4&hl=en&ct=clnk&gl=ca&source=www.google.ca">found这里

Something to consider is a testing framework like flexunit to automate many of the tasks. A good starting point for tutorials on flexunit and Test Driven Development can be found here

编辑:我要指出的FlexUnit 纯AS3工程,以及

I should note that FlexUnit works for pure AS3 as well

这篇关于单元测试AS3 code为Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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