Class: Buildr::Scala::ScalaTest
- Inherits:
-
TestFramework::Java
- Object
- TestFramework::Base
- TestFramework::Java
- Buildr::Scala::ScalaTest
- Defined in:
- lib/buildr/scala/tests.rb
Overview
ScalaTest framework, the default test framework for Scala tests.
Support the following options:
-
:properties – Hash of system properties available to the test case.
-
:environment – Hash of environment variables available to the test case.
-
:java_args – Arguments passed as is to the JVM.
Constant Summary collapse
- VERSION =
'1.0'
Instance Attribute Summary collapse
-
#group_excludes ⇒ Object
annotation-based group exclusion.
-
#group_includes ⇒ Object
annotation-based group inclusion.
Attributes inherited from TestFramework::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(test_task, options) ⇒ ScalaTest
constructor
A new instance of ScalaTest.
-
#run(scalatest, dependencies) ⇒ Object
:nodoc:.
-
#tests(dependencies) ⇒ Object
:nodoc:.
Methods inherited from TestFramework::Base
Constructor Details
#initialize(test_task, options) ⇒ ScalaTest
Returns a new instance of ScalaTest.
85 86 87 88 89 |
# File 'lib/buildr/scala/tests.rb', line 85 def initialize(test_task, ) super @group_includes = [] @group_excludes = [] end |
Instance Attribute Details
#group_excludes ⇒ Object
annotation-based group exclusion
83 84 85 |
# File 'lib/buildr/scala/tests.rb', line 83 def group_excludes @group_excludes end |
#group_includes ⇒ Object
annotation-based group inclusion
80 81 82 |
# File 'lib/buildr/scala/tests.rb', line 80 def group_includes @group_includes end |
Class Method Details
.applies_to?(project) ⇒ Boolean
:nodoc:
67 68 69 |
# File 'lib/buildr/scala/tests.rb', line 67 def applies_to?(project) #:nodoc: !Dir[project.path_to(:source, :test, :scala, '**/*.scala')].empty? end |
.dependencies ⇒ Object
62 63 64 65 |
# File 'lib/buildr/scala/tests.rb', line 62 def dependencies ["org.scalatest:scalatest:jar:#{version}"] + Check.dependencies + JMock.dependencies + JUnit.dependencies end |
Instance Method Details
#run(scalatest, dependencies) ⇒ Object
:nodoc:
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 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/buildr/scala/tests.rb', line 95 def run(scalatest, dependencies) #:nodoc: mkpath task.report_to.to_s success = [] = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted scalatest.each do |suite| info "ScalaTest #{suite.inspect}" # Use Ant to execute the ScalaTest task, gives us performance and reporting. reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt") taskdef = Buildr.artifacts(self.class.dependencies).each(&:invoke).map(&:to_s) Buildr.ant('scalatest') do |ant| ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask', :classpath=>taskdef.join(File::PATH_SEPARATOR) ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do ant.suite :classname=>suite ant.reporter :type=>'stdout', :config=> ant.reporter :type=>'file', :filename=> reportFile, :config=> # TODO: This should be name=>value pairs! #ant.includes group_includes.join(" ") if group_includes #ant.excludes group_excludes.join(" ") if group_excludes ([:properties] || []).each { |name, value| ant.config :name=>name, :value=>value } end end # Parse for failures, errors, etc. # This is a bit of a pain right now because ScalaTest doesn't flush its # output synchronously before the Ant test finishes so we have to loop # and wait for an indication that the test run was completed. failed = false completed = false wait = 0 while (!completed) do File.open(reportFile, "r") do |input| while (line = input.gets) do failed = (line =~ /(TESTS? FAILED)|(RUN STOPPED)|(RUN ABORTED)/) unless failed completed |= (line =~ /Run completed/) break if (failed) end end wait += 1 break if (failed || wait > 10) unless completed sleep(1) end end success << suite if (completed && !failed) end success end |
#tests(dependencies) ⇒ Object
:nodoc:
91 92 93 |
# File 'lib/buildr/scala/tests.rb', line 91 def tests(dependencies) #:nodoc: filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite}) end |