Class: Buildr::AS3::Test::FlexUnit4
- Inherits:
-
TestFramework::AS3
- Object
- TestFramework::AS3
- Buildr::AS3::Test::FlexUnit4
- Defined in:
- lib/buildr/as3/test/flexunit4.rb
Overview
FlexUnit4 test framework.
Support the following options:
-
:player – [“air”,“flash”] defines the player to run the tests, when not set it chooses based on the projects compiler.
-
:haltonFailure – [Boolean] stop unit-testing on error
-
:verbose – [Boolean] print additional info
-
:localTrusted – [Boolean] some sandbox thing
-
:htmlreport – [Boolean] set to true if you want to create a JUnit HTML report
Constant Summary collapse
- VERSION =
'4.1.0_RC2-4'
- FLEX_SDK_VERSION =
'4.1.0.16076'
Class Method Summary collapse
Instance Method Summary collapse
-
#run(tests, dependencies) ⇒ Object
:nodoc:.
-
#tests(dependencies) ⇒ Object
:nodoc:.
Class Method Details
.flexunit_taskdef ⇒ Object
:nodoc:
44 45 46 |
# File 'lib/buildr/as3/test/flexunit4.rb', line 44 def flexunit_taskdef #:nodoc: "com.adobe.flexunit:flexunitUnitTasks:jar:#{VERSION}" end |
.swc_dependencies ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/buildr/as3/test/flexunit4.rb', line 48 def swc_dependencies [ "com.adobe.flexunit:flexunit:swc:as3_#{FLEX_SDK_VERSION}:#{VERSION}", "com.adobe.flexunit:flexunit:swc:flex_#{FLEX_SDK_VERSION}:#{VERSION}", "com.adobe.flexunit:flexunit-aircilistener:swc:#{FLEX_SDK_VERSION}:#{VERSION}", "com.adobe.flexunit:flexunit-cilistener:swc:#{FLEX_SDK_VERSION}:#{VERSION}", "com.adobe.flexunit:flexunit-flexcoverlistener:swc:#{FLEX_SDK_VERSION}:#{VERSION}", "com.adobe.flexunit:flexunit-uilistener:swc:#{FLEX_SDK_VERSION}:#{VERSION}" ] end |
Instance Method Details
#run(tests, dependencies) ⇒ Object
:nodoc:
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/buildr/as3/test/flexunit4.rb', line 76 def run(tests, dependencies) #:nodoc: report_dir = task.project._(:reports, FlexUnit4.to_sym) FileUtils.mkdir_p report_dir project_dir = Dir.getwd Dir.chdir report_dir taskdef = Buildr.artifact(FlexUnit4.flexunit_taskdef) taskdef.invoke player = "air" if [:airmxmlc, :airompc].include?(task.project.compile.compiler) || [:player] == "air" player ||= "flash" Buildr.ant("flexunit4") do |ant| ant.property :name => "FLEX_HOME", :location=>task.project.compile.[:flexsdk].home ant.taskdef :resource => "flexUnitTasks.tasks", :classpath => taskdef.to_s ant.flexunit :player => player, :haltonFailure => [:haltonFailure] || false, :verbose => [:verbose] || false, :localTrusted => [:localTrusted] || true, :headless => [:headless] || false, :display => [:display] || 99, :swf => task.project.get_as3_output(true) ant.taskdef :name=>'junitreport', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator', :classpath=>Buildr.artifacts(JUnit.ant_taskdef).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR) unless [:htmlreport] == false ant.junitreport :todir => report_dir do ant.fileset :dir => report_dir do ant.include :name => "TEST-*.xml" end ant.report :format => "frames", :todir => report_dir + "/html" end end Dir[report_dir+"/TEST-*.xml"].each do |xml_report| doc = REXML::Document.new File.new(xml_report) name = doc.elements["testsuite"].attributes["name"] failures = Integer(doc.elements["testsuite"].attributes["failures"]) errors = Integer(doc.elements["testsuite"].attributes["errors"]) tests -= [name] unless failures + errors == 0 end end Dir.chdir project_dir tests end |
#tests(dependencies) ⇒ Object
:nodoc:
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/buildr/as3/test/flexunit4.rb', line 60 def tests(dependencies) #:nodoc: candidates = [] task.project.test.compile.sources.each do |source| files = Dir["#{source}/**/*Test.as"] + Dir["#{source}/**/*Test.mxml"] files.each { |item| if File.dirname(item) == source candidates << File.basename(item, '.*') else candidates << File.dirname(item).gsub!(source+"/", "").gsub!("/", ".")+"."+File.basename(item, '.*') end } end candidates end |