Class: Buildr::TestNG
- Inherits:
-
Buildr::TestFramework::Java
- Object
- Buildr::TestFramework::Base
- Buildr::TestFramework::Java
- Buildr::TestNG
- Defined in:
- lib/buildr/java/tests.rb
Overview
TestNG test framework. To use in your project:
test.using :testng
Support the following options:
-
:properties – Hash of properties passed to the test suite.
-
:java_args – Arguments passed to the JVM.
-
:args – Arguments passed to the TestNG command line runner.
Instance Attribute Summary
Attributes inherited from Buildr::TestFramework::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#run(tests, dependencies) ⇒ Object
:nodoc:.
-
#tests(dependencies) ⇒ Object
:nodoc:.
Methods inherited from Buildr::TestFramework::Java
Methods inherited from Buildr::TestFramework::Base
applies_to?, #dependencies, #initialize, to_sym
Constructor Details
This class inherits a constructor from Buildr::TestFramework::Base
Class Method Details
.dependencies ⇒ Object
53 54 55 |
# File 'lib/buildr/java/tests.rb', line 53 def dependencies %w(org.testng:testng:jar:7.4.0 com.beust:jcommander:jar:1.78 org.webjars:jquery:jar:3.5.1) end |
Instance Method Details
#run(tests, dependencies) ⇒ Object
:nodoc:
67 68 69 70 71 72 73 74 75 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 |
# File 'lib/buildr/java/tests.rb', line 67 def run(tests, dependencies) #:nodoc: cmd_args = [] cmd_args << '-suitename' << task.project.id cmd_args << '-log' << '2' cmd_args << '-d' << task.report_to.to_s exclude_args = [:excludegroups] || [] unless exclude_args.empty? cmd_args << '-excludegroups' << exclude_args.join(',') end groups_args = [:groups] || [] unless groups_args.empty? cmd_args << '-groups' << groups_args.join(',') end # run all tests in the same suite cmd_args << '-testclass' << tests.join(',') cmd_args += [:args] if [:args] = { :properties=>[:properties], :java_args=>[:java_args], :classpath=>dependencies, :name => "TestNG in #{task.send(:project).name}" } tmp = nil begin tmp = Tempfile.open('testNG') tmp.write cmd_args.join("\n") tmp.close Java::Commands.java ['org.testng.TestNG', "@#{tmp.path}"], ensure tmp.close unless tmp.nil? end # testng-failed.xml contains the list of failed tests *only* failed_tests = File.join(task.report_to.to_s, task.project.id.to_s, 'Command line test.xml') if File.exist?(failed_tests) report = File.read(failed_tests) failed = report.scan(/<testcase [^>]+ classname="([^"]+)">/im).flatten # return the list of passed tests tests - failed else tests end end |
#tests(dependencies) ⇒ Object
:nodoc:
58 59 60 61 62 63 64 65 |
# File 'lib/buildr/java/tests.rb', line 58 def tests(dependencies) #:nodoc: candidates = derive_test_candidates # Ugly hack that probably works for all of our codebases test_include = /.*Test$/ test_exclude = /(^|\.)Abstract[^.]*$/ candidates.select{|c| c =~ test_include }.select{|c| !(c =~ test_exclude) }.dup end |