Class List Method List File List

# Class: VertxUnit::TestSuite

Inherits:
  Object
  - Object
  - VertxUnit::TestSuite
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/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)

- + (::VertxUnit::TestSuite) create(name = nil)
  Create and return a new test suite.

## Instance Method Summary (collapse)

- - (self) after { ... }
  Set a callback executed after the tests.
- - (self) after_each { ... }
  Set a callback executed after each test and before the suite after callback.
- - (self) before { ... }
  Set a callback executed before the tests.
- - (self) before_each { ... }
  Set a callback executed before each test and after the suite before callback.
- - (::VertxUnit::TestCompletion) run(param_1 = nil, param_2 = nil)
  Run the testsuite with the specified options and the specified vertx instance.
- - (self) test(name = nil) { ... }
  Add a new test case to the suite.

## 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:

- (`::VertxUnit::TestSuite`) —
  the created test suite

Raises:

- (`ArgumentError`)

    31
    32
    33
    34
    35
    36
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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:

- - (`::VertxUnit::TestCompletion`) run(options)

  Parameters:

  - options (`Hash`) —
    the test options
- - (`::VertxUnit::TestCompletion`) run(vertx)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vertx instance
- - (`::VertxUnit::TestCompletion`) run(vertx, options)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vertx instance
  - options (`Hash`) —
    the test options

Returns:

- (`::VertxUnit::TestCompletion`) —
  the related test completion

Raises:

- (`ArgumentError`)

    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_suite.rb', line 102

    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) { ... }

Add a new test case to the suite.

Parameters:

- name (`String`) (defaults to: `nil`) —
  the test case name

Yields:

- the test case

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    81
    82
    83
    84
    85
    86
    87
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_suite.rb', line 81

    def test(name=nil)
      if name.class == String && block_given?
        @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
      end
      raise ArgumentError, "Invalid arguments when calling test(name)"
    end