如何在IDE或构建脚本中对Flex应用程序进行单元测试?

时间:2023-01-24 18:30:51

I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of FlexUnit but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one exist?

我目前正在开发一个使用Adobe Flex 3编写的前端的应用程序。我知道FlexUnit,但我真正喜欢的是Ant / NAnt的单元测试运行器和与Flex Builder IDE集成的运行器( AKA Eclipse)。有一个存在吗?

Also, are there any other resources on how to do Flex development "the right way" besides the Cairngorm microarchitecture example?

另外,除了Cairngorm微体系结构示例之外,还有其他任何关于如何以“正确的方式”进行Flex开发的资源吗?

4 个解决方案

#1


4  

The dpUint testing framework has a test runner built with AIR which can be integrated with a build script.

dpUint测试框架有一个使用AIR构建的测试运行器,可以与构建脚本集成。

There is also my FlexUnit automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:

还有我的FlexUnit自动化套件,它对FlexUnit的功能大致相同。它有一个Ant宏,可以将测试作为Ant脚本的一部分运行,例如:

<target name="run-tests" depends="compile-tests">
  <flexunit swf="${build.home}/tests.swf" failonerror="true"/>
</target>

#2


3  

On my project we're using Maven to build both our Flex RIA and the Java-based back end. In order to build and test the Flex app we use the flex-mojos maven plugins. They do a great job for us and I would highly recommend using Maven over Ant.

在我的项目中,我们使用Maven来构建我们的Flex RIA和基于Java的后端。为了构建和测试Flex应用程序,我们使用flex-mojos maven插件。他们为我们做了很好的工作,我强烈建议使用Maven over Ant。

That being said, if you're already using Ant it can be a little tricky to transition over to Maven. So if you're in that position I would recommend using the flexunit tasks available here: Ant Task

话虽这么说,如果你已经在使用Ant,转换到Maven可能有点棘手。因此,如果您处于该位置,我建议您使用此处提供的flexunit任务:Ant Task

Both of these libraries do basically the same thing, they launch a generated flexunit test runner mxml application in a window and open a socket connection back to the build process using a JUnit test runner. Amazingly enough it works pretty well. The only problem is that you can't run it headless so if you want to run the build from a CI server you have to make sure that process has the ability to launch new windows otherwise it won't work.

这两个库基本上都是一样的,它们在一个窗口中启动生成的flexunit测试运行器mxml应用程序,并使用JUnit测试运行器打开一个套接字连接回构建过程。令人惊讶的是它的效果非常好。唯一的问题是你不能无头地运行它所以如果你想从CI服务器运行构建,你必须确保该进程能够启动新窗口,否则它将无法工作。

#3


2  

About how to develop Flex applications the right way, I wouldn't look too much at the Cairngorm framework. It does claim to show "best practice" and so on, but I would say that the opposite is true. It's based around the use of global variables, and other things you should try to avoid. I've outlined some of the problems on my blog.

关于如何以正确的方式开发Flex应用程序,我不会过多地关注Cairngorm框架。它确实声称显示“最佳实践”等等,但我会说相反的是真的。它基于全局变量的使用,以及您应该尽量避免的其他事情。我在博客上概述了一些问题。

I would suggest that you look at the Mate framework instead, which has good documentation and good examples to get you going. It uses Flex to its full potential, doesn't rely on global variables as Cairngorm and PureMVC, and it makes it possible to write much more decoupled code.

我建议你看一下Mate框架,它有很好的文档和很好的例子来帮助你。它充分发挥了Flex的潜力,不依赖于Cairngorm和PureMVC等全局变量,并且可以编写更多的解耦代码。

#4


0  

An alternative to FlexUnit is the AsUnit testing tools. There are versions for actionscript 2 and 3. It also has good integration with Project Sprouts, which is a build tool for Flex and Flash similar to ant, however it uses ruby rake tasks and includes excellent dependency management along the lines of maven.

FlexUnit的替代品是AsUnit测试工具。还有动作脚本2和3的版本。它还与Project Sprouts很好地集成,这是一个类似于ant的Flex和Flash的构建工具,但是它使用ruby rake任务,并且包含了与maven一致的出色依赖管理。

No IDE integration that I know of however.

但是,我知道没有IDE集成。

#1


4  

The dpUint testing framework has a test runner built with AIR which can be integrated with a build script.

dpUint测试框架有一个使用AIR构建的测试运行器,可以与构建脚本集成。

There is also my FlexUnit automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:

还有我的FlexUnit自动化套件,它对FlexUnit的功能大致相同。它有一个Ant宏,可以将测试作为Ant脚本的一部分运行,例如:

<target name="run-tests" depends="compile-tests">
  <flexunit swf="${build.home}/tests.swf" failonerror="true"/>
</target>

#2


3  

On my project we're using Maven to build both our Flex RIA and the Java-based back end. In order to build and test the Flex app we use the flex-mojos maven plugins. They do a great job for us and I would highly recommend using Maven over Ant.

在我的项目中,我们使用Maven来构建我们的Flex RIA和基于Java的后端。为了构建和测试Flex应用程序,我们使用flex-mojos maven插件。他们为我们做了很好的工作,我强烈建议使用Maven over Ant。

That being said, if you're already using Ant it can be a little tricky to transition over to Maven. So if you're in that position I would recommend using the flexunit tasks available here: Ant Task

话虽这么说,如果你已经在使用Ant,转换到Maven可能有点棘手。因此,如果您处于该位置,我建议您使用此处提供的flexunit任务:Ant Task

Both of these libraries do basically the same thing, they launch a generated flexunit test runner mxml application in a window and open a socket connection back to the build process using a JUnit test runner. Amazingly enough it works pretty well. The only problem is that you can't run it headless so if you want to run the build from a CI server you have to make sure that process has the ability to launch new windows otherwise it won't work.

这两个库基本上都是一样的,它们在一个窗口中启动生成的flexunit测试运行器mxml应用程序,并使用JUnit测试运行器打开一个套接字连接回构建过程。令人惊讶的是它的效果非常好。唯一的问题是你不能无头地运行它所以如果你想从CI服务器运行构建,你必须确保该进程能够启动新窗口,否则它将无法工作。

#3


2  

About how to develop Flex applications the right way, I wouldn't look too much at the Cairngorm framework. It does claim to show "best practice" and so on, but I would say that the opposite is true. It's based around the use of global variables, and other things you should try to avoid. I've outlined some of the problems on my blog.

关于如何以正确的方式开发Flex应用程序,我不会过多地关注Cairngorm框架。它确实声称显示“最佳实践”等等,但我会说相反的是真的。它基于全局变量的使用,以及您应该尽量避免的其他事情。我在博客上概述了一些问题。

I would suggest that you look at the Mate framework instead, which has good documentation and good examples to get you going. It uses Flex to its full potential, doesn't rely on global variables as Cairngorm and PureMVC, and it makes it possible to write much more decoupled code.

我建议你看一下Mate框架,它有很好的文档和很好的例子来帮助你。它充分发挥了Flex的潜力,不依赖于Cairngorm和PureMVC等全局变量,并且可以编写更多的解耦代码。

#4


0  

An alternative to FlexUnit is the AsUnit testing tools. There are versions for actionscript 2 and 3. It also has good integration with Project Sprouts, which is a build tool for Flex and Flash similar to ant, however it uses ruby rake tasks and includes excellent dependency management along the lines of maven.

FlexUnit的替代品是AsUnit测试工具。还有动作脚本2和3的版本。它还与Project Sprouts很好地集成,这是一个类似于ant的Flex和Flash的构建工具,但是它使用ruby rake任务,并且包含了与maven一致的出色依赖管理。

No IDE integration that I know of however.

但是,我知道没有IDE集成。