Class: VertxUnit::TestSuite

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb

Overview

A named suite of test cases that are executed altogether. The suite suite is created with the #create and the returned suite contains initially no tests.

The suite can declare a callback before the suite with #before or after the suite with #after.

The suite can declare a callback before each test with #before_each or after each test with #after_each.

Each test case of the suite is declared by calling the #test method.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (::VertxUnit::TestSuite) create(name = nil)

Create and return a new test suite.

Parameters:

  • name (String) (defaults to: nil)
    the test suite name

Returns:

Raises:

  • (ArgumentError)


31
32
33
34
35
36
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 31

def self.create(name=nil)
  if name.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtUnit::TestSuite.java_method(:create, [Java::java.lang.String.java_class]).call(name),::VertxUnit::TestSuite)
  end
  raise ArgumentError, "Invalid arguments when calling create(name)"
end

Instance Method Details

- (self) after { ... }

Set a callback executed after the tests.

Yields:

  • the callback

Returns:

  • (self)

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 60

def after
  if block_given?
    @j_del.java_method(:after, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxUnit::TestContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling after()"
end

- (self) after_each { ... }

Set a callback executed after each test and before the suite after callback.

Yields:

  • the callback

Returns:

  • (self)

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 70

def after_each
  if block_given?
    @j_del.java_method(:afterEach, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxUnit::TestContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling after_each()"
end

- (self) before { ... }

Set a callback executed before the tests.

Yields:

  • the callback

Returns:

  • (self)

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 40

def before
  if block_given?
    @j_del.java_method(:before, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxUnit::TestContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling before()"
end

- (self) before_each { ... }

Set a callback executed before each test and after the suite before callback.

Yields:

  • the callback

Returns:

  • (self)

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 50

def before_each
  if block_given?
    @j_del.java_method(:beforeEach, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxUnit::TestContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling before_each()"
end

- (::VertxUnit::TestCompletion) run - (::VertxUnit::TestCompletion) run(options) - (::VertxUnit::TestCompletion) run(vertx) - (::VertxUnit::TestCompletion) run(vertx, options)

Run the testsuite with the specified options and the specified vertx instance.

The test suite will be executed on the event loop provided by the vertx argument when Hash#set_use_event_loop is not set to false. The returned Completion object can be used to get a completion callback.

Overloads:

Returns:

Raises:

  • (ArgumentError)


106
107
108
109
110
111
112
113
114
115
116
117
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 106

def run(param_1=nil,param_2=nil)
  if !block_given? && param_1 == nil && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:run, []).call(),::VertxUnit::TestCompletion)
  elsif param_1.class == Hash && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:run, [Java::IoVertxExtUnit::TestOptions.java_class]).call(Java::IoVertxExtUnit::TestOptions.new(::Vertx::Util::Utils.to_json_object(param_1))),::VertxUnit::TestCompletion)
  elsif param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:run, [Java::IoVertxCore::Vertx.java_class]).call(param_1.j_del),::VertxUnit::TestCompletion)
  elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:run, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtUnit::TestOptions.java_class]).call(param_1.j_del,Java::IoVertxExtUnit::TestOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxUnit::TestCompletion)
  end
  raise ArgumentError, "Invalid arguments when calling run(param_1,param_2)"
end

- (self) test(name = nil, repeat = nil) { ... }

Add a new test case to the suite.

Parameters:

  • name (String) (defaults to: nil)
    the test case name
  • repeat (Fixnum) (defaults to: nil)
    the number of times the test should be repeated

Yields:

  • the test case

Returns:

  • (self)

Raises:

  • (ArgumentError)


82
83
84
85
86
87
88
89
90
91
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_suite.rb', line 82

def test(name=nil,repeat=nil)
  if name.class == String && block_given? && repeat == nil
    @j_del.java_method(:test, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(name,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxUnit::TestContext)) }))
    return self
  elsif name.class == String && repeat.class == Fixnum && block_given?
    @j_del.java_method(:test, [Java::java.lang.String.java_class,Java::int.java_class,Java::IoVertxCore::Handler.java_class]).call(name,repeat,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxUnit::TestContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling test(name,repeat)"
end