从命令行构建并运行 FlexUnit
我正在使用 ActionScript3 和 Flash Builder 4 作为我的 IDE 构建一个应用程序。
IDE 支持称为“FlexUnit”的单元测试框架。
我可以在 IDE 中构建并运行测试,没问题。
经过很多痛苦和磨难后,我弄清楚了如何从命令行将单元测试构建为 swf。我可以将浏览器或 Flash 播放器指向 swf 并运行测试。
但对于自动化构建系统来说,这并不好:我想构建测试,运行它们,并收集/分析结果以判断哪些测试(如果有)失败。
我可以想象一些黑客行为:破解 FlexUnit 基础库以将输出转储到 stderr 而不仅仅是 IDE 控制台。一起破解一些脚本,将浏览器指向 swf,数到 60,终止浏览器并检查 stderr。
但这太可怕了。
我必须相信有某种从命令行构建和运行的方法可以很好地与自动构建系统配合使用。
更复杂的是:我对 ActionScript 是一个相对菜鸟(大约 1 个月)。我的背景是 C++、makefile 等。我必须做的所有事情,甚至是在 ide 之外构建的测试(build.xml 文件,ant)对我来说都是完全希腊语,只需从我能找到的示例中剪切粘贴即可。
I am building an app using ActionScript3 with Flash Builder 4 as my IDE.
The IDE supports a unit testing framework called "FlexUnit".
I can build and run tests within the IDE, no problem.
After much pain and suffering I figured out how to build the unit tests as a swf from the command line. I can point a browser or flash player at the swf and the tests run.
But for an automated build system this is no good: I would like to build the tests, run them, and collect/analyze the results to tell which tests, if any, are failing.
I can imaging some hackery: hack FlexUnit base libraries to dump output to stderr instead of just to the IDE console. Hack some script together that points a browser at the swf, counts to 60, kills the browser and checks stderr.
But that's hideous.
I have to believe there's some way to build and run from the command line that works nicely with automated build systems.
Further complication: I am a relative noob with ActionScript (~1 month). My background is C++, makefiles, etc. All the stuff I had to do to get the tests even to build outside the ide (a build.xml file, ant) was complete greek to me, just cut n pasting from examples I could find.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,运行 swf 的唯一选择是在浏览器或独立播放器中。只要您可以获得测试结果并退出应用程序,在播放器中运行对于您的持续集成环境来说应该不是问题。
要将测试结果打印到标准输出,您需要向 testunit 核心实例添加一个文本侦听器。
core.addListener( TextListener.getDefaultTextListener( LogEventLevel.DEBUG ) );
要在测试运行后退出应用程序...
System.exit(0);
例如,您的顶级 mxml 文件可能如下所示...
然后您需要做的就是解析输出。
它不像我们希望的那么优雅,但它应该可以工作。
As far as I'm aware your only options for running the swf are in the browser or in the standalone player. Running in the player should not be a problem for your continuous integration environment as long as you can get at the test results and exit the application.
To print test results to stdout you need to add a Text listener to your testunit core instance.
core.addListener( TextListener.getDefaultTextListener( LogEventLevel.DEBUG ) );
To exit the application after the tests have run...
System.exit(0);
For example, your top level mxml file might look like this...
Then all you need to do is parse the output.
It's not as elegant as we might like but it should work.
这篇文章有一个解决方案:http://devnet.jetbrains.com/message/5507979#5507979。对我来说就像冠军一样。
This post have a solution : http://devnet.jetbrains.com/message/5507979#5507979 . Works for me like a champ.