我正在用Flex 4.11.0和AIR 4.0构建一个移动应用程序。我的IDE是FlashBuilder4.7。我编写了许多单元测试,其中一些使用AIR功能,如文件系统访问。
我正试图把这个项目整合到詹金斯的CI工作中。我有一个ANT在执行以下操作:
现在我想要的是编写一个ANT来启动我的单元测试,并用XML或生成一个报告,然后由Jenkins解析。
我尝试了以下几种方法:-遵循关于http://tutorials.digitalprimates.net/flexunit/Unit-16.html的教程,并让这个示例开始工作。然而,这是一个闪存项目,而不是AIR项目!--阅读https://cwiki.apache.org/confluence/display/FLEX/FlexUnit+Ant+Task上的文档,下载并构建git@github.com中的FlexUnit代码:flexunit/Flexunit.git以获取FlexUnit4AIRCIListener.swc --在互联网上从各地读取大量信息,找不到答案(我找到了一些提示,但很多信息已经过时或引用死链接)
到目前为止,我所掌握的情况如下:
<taskdef resource="flexUnitTasks.tasks" classpath="${basedir}\libs\flexUnitTasks-4.1.0.jar" />
<target name="test" >
<echo>Testing...</echo>
<echo>==========</echo>
<!-- 1. Compile FlexUnit-Application -->
<mxmlc file="${PROJECT.src}\FlexUnit.mxml" output="FlexUnit.swf" >
<load-config filename="D:\tools\sdk\flex\4.11.0_AIR4.0\frameworks\air-config.xml" append="true" />
<source-path path-element="${PROJECT.src}" />
<source-path path-element="${basedir}\test" />
<library-path dir="${PROJECT.libs}" append="true">
<include name="**/*.swc" />
<include name="**/*.ane" />
</library-path>
<library-path dir="D:\tools\sdk\flex\4.11.0_AIR4.0\frameworks\libs\air" append="true">
<include name="airglobal.swc" />
</library-path>
<compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
<compiler.headless-server>true</compiler.headless-server>
</mxmlc>
<!-- 2. Run the compiled SWF -->
<flexunit swf="FlexUnit.swf"
player="air"
timeout="180000"
toDir="${OUTPUT.root}\flexUnit"
haltonfailure="false"
verbose="true"
localTrusted="true"
/>
<!-- 3. Generate readable JUnit-style reports -->
<junitreport todir="${OUTPUT.root}\flexUnit">
<fileset dir="${OUTPUT.root}\flexUnit">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${OUTPUT.root}\flexUnit\html" />
</junitreport>
</target>下面是我的FlexUnit.mxml-Application的相关部分:
protected function onCreationComplete(event:FlexEvent):void
{
core = new FlexUnitCore();
core.addListener(new AirCIListener());
core.run(currentRunTestSuite());
}
public function currentRunTestSuite():Array
{
var testsToRun:Array = new Array();
testsToRun.push(test.suites.CLXSatelliteTestSuite);
return testsToRun;
}从ANT工作的步骤1. (至少我得到了FlexUnit.swf)。但是,在<flexunit>-Task中启动SWF失败:
VerifyError: Error #1014: Class flash.filesystem::File could not be found.控制台输出:柔性单元生成默认值..。使用默认工作dir D:\workspace\flex\project\clx-卫星使用下列设置为测试运行: FLEX_HOME: D:\tools\sdk\flex\4.11.0_AIR4.0哈尔顿故障:假无头:假显示: 99 localTrusted:真播放器:闪存端口: 1024 swf: FLEX_HOME超时:1800 up : D:\workspaces\flex\projects\clx-satellite\deploy\flexUnit设置服务器进程.柔性单元启动服务器..。在端口1024上打开服务器套接字。柔性单元等待客户连接..。柔性单元OS: Windows启动播放器:使用参数执行“rundll32”的柔性单元:柔性单元“url.dll,FileProtocolHandler”--柔性单元“可执行文件”和“参数”周围的字符不是命令的一部分。柔性单元客户端连接。柔性单元将入站缓冲区大小设置为262144字节。柔性单元接收数据..。柔性单元发送确认给玩家开始发送测试数据.柔性单元停止服务器..。测试数据到达挠曲单元结束,发送确认给玩家.
BUILD FAILED
D:\workspaces\flex\projects\clx-satellite\build.xml:148:
java.util.concurrent.ExecutionException: could not close client/server socket当我包含一个不使用File-Class的测试时,测试工作正常,我得到了一个类似的错误(ReferenceError: Error #1065: Variable flash.desktop::NativeApplication is not defined.),但至少测试通过了,我得到了XML-输出。在我看来,FlexUnit与AIR并不完全兼容,尽管我在任务中使用了player=air。
你们中有谁有通过ANT使用FlexUnit运行AIR应用程序(可能是移动应用程序)的运行单元测试的示例吗?
发布于 2014-04-05 15:12:55
没关系,我自己搞清楚了,并在我的个人博客上写到:http://www.tiefenauer.info/ci-for-flex-mobile-applications-part-3-performing-unit-tests/。
我描述了一个完整的CI过程,以防万一任何人都有同样的问题。
发布于 2016-05-13 21:26:59
这里有Apache FlexUnit特性请求:Apache FlexUnit: FLEX-35090
也可以通过使用FlexUnit 4.1:additionalCompilerOptions分支的分叉编译自己的FlexUnit任务来利用这个特性。
自定义FlexUnit Ant任务支持的格式设置如下:
<flexunit
workingDir="${bin.loc}"
toDir="${report.loc}"
haltonfailure="false"
verbose="true"
localTrusted="true" >
<!-- only supported with custom FlexUnit Ant tasks -->
<additionalCompilerOption option="-define+=MY_CONST::foo,'BAR'" />
</flexunit>https://stackoverflow.com/questions/21474402
复制相似问题