Class: VertxUnit::TestContext
- Inherits:
-
Object
- Object
- VertxUnit::TestContext
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb
Overview
The test context is used for performing test assertions and manage the completion of the test. This context
is provided by vertx-unit as argument of the test case.
Instance Method Summary (collapse)
-
- (self) assert_equals(expected = nil, actual = nil, message = nil)
Assert the expected argument is equals to the actual argument.
-
- (self) assert_false(condition = nil, message = nil)
Assert the specified condition is false.
-
- (self) assert_in_range(expected = nil, actual = nil, delta = nil, message = nil)
Asserts that the expected double argument is equals to the actual double argument within a positive delta.
-
- (self) assert_not_equals(first = nil, second = nil, message = nil)
Assert the first argument is not equals to the second argument.
-
- (self) assert_not_null(expected = nil, message = nil)
Assert the expected argument is not null.
-
- (self) assert_null(expected = nil, message = nil)
Assert the expected argument is null.
-
- (self) assert_true(condition = nil, message = nil)
Assert the specified condition is true.
-
- (::VertxUnit::Async) async(count = nil)
Create and returns a new async object, the returned async controls the completion of the test.
-
- (Proc) async_assert_failure { ... }
Creates and returns a new async handler, the returned handler controls the completion of the test.
-
- (Proc) async_assert_success { ... }
Creates and returns a new async handler, the returned handler controls the completion of the test.
-
- (Proc) exception_handler
@return an exception handler that will fail this context.
-
- (void) fail(param_1 = nil)
Throw a failure with the specified failure cause.
-
- (Object) get(key = nil)
Get some data from the context.
-
- (Object) put(key = nil, value = nil)
Put some data in the context.
-
- (Object) remove(key = nil)
Remove some data from the context.
Instance Method Details
- (self) assert_equals(expected = nil, actual = nil, message = nil)
Assert the
expected
argument is equals to the actual
argument. If the arguments are not equals
an assertion error is thrown otherwise the execution continue.
114 115 116 117 118 119 120 121 122 123 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 114 def assert_equals(expected=nil,actual=nil,=nil) if (expected.class == String || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && (actual.class == String || actual.class == Hash || actual.class == Array || actual.class == NilClass || actual.class == TrueClass || actual.class == FalseClass || actual.class == Fixnum || actual.class == Float) && !block_given? && == nil @j_del.java_method(:assertEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(expected),::Vertx::Util::Utils.to_object(actual)) return self elsif (expected.class == String || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && (actual.class == String || actual.class == Hash || actual.class == Array || actual.class == NilClass || actual.class == TrueClass || actual.class == FalseClass || actual.class == Fixnum || actual.class == Float) && .class == String && !block_given? @j_del.java_method(:assertEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(expected),::Vertx::Util::Utils.to_object(actual),) return self end raise ArgumentError, "Invalid arguments when calling assert_equals(expected,actual,message)" end |
- (self) assert_false(condition = nil, message = nil)
Assert the specified
condition
is false
. If the condition is true
, an assertion error is thrown
otherwise the execution continue.
98 99 100 101 102 103 104 105 106 107 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 98 def assert_false(condition=nil,=nil) if (condition.class == TrueClass || condition.class == FalseClass) && !block_given? && == nil @j_del.java_method(:assertFalse, [Java::boolean.java_class]).call(condition) return self elsif (condition.class == TrueClass || condition.class == FalseClass) && .class == String && !block_given? @j_del.java_method(:assertFalse, [Java::boolean.java_class,Java::java.lang.String.java_class]).call(condition,) return self end raise ArgumentError, "Invalid arguments when calling assert_false(condition,message)" end |
- (self) assert_in_range(expected = nil, actual = nil, delta = nil, message = nil)
Asserts that the
expected
double argument is equals to the actual
double argument
within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise
the execution continue.
132 133 134 135 136 137 138 139 140 141 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 132 def assert_in_range(expected=nil,actual=nil,delta=nil,=nil) if expected.class == Float && actual.class == Float && delta.class == Float && !block_given? && == nil @j_del.java_method(:assertInRange, [Java::double.java_class,Java::double.java_class,Java::double.java_class]).call(::Vertx::Util::Utils.to_double(expected),::Vertx::Util::Utils.to_double(actual),::Vertx::Util::Utils.to_double(delta)) return self elsif expected.class == Float && actual.class == Float && delta.class == Float && .class == String && !block_given? @j_del.java_method(:assertInRange, [Java::double.java_class,Java::double.java_class,Java::double.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_double(expected),::Vertx::Util::Utils.to_double(actual),::Vertx::Util::Utils.to_double(delta),) return self end raise ArgumentError, "Invalid arguments when calling assert_in_range(expected,actual,delta,message)" end |
- (self) assert_not_equals(first = nil, second = nil, message = nil)
Assert the
first
argument is not equals to the second
argument. If the arguments are equals
an assertion error is thrown otherwise the execution continue.
148 149 150 151 152 153 154 155 156 157 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 148 def assert_not_equals(first=nil,second=nil,=nil) if (first.class == String || first.class == Hash || first.class == Array || first.class == NilClass || first.class == TrueClass || first.class == FalseClass || first.class == Fixnum || first.class == Float) && (second.class == String || second.class == Hash || second.class == Array || second.class == NilClass || second.class == TrueClass || second.class == FalseClass || second.class == Fixnum || second.class == Float) && !block_given? && == nil @j_del.java_method(:assertNotEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(first),::Vertx::Util::Utils.to_object(second)) return self elsif (first.class == String || first.class == Hash || first.class == Array || first.class == NilClass || first.class == TrueClass || first.class == FalseClass || first.class == Fixnum || first.class == Float) && (second.class == String || second.class == Hash || second.class == Array || second.class == NilClass || second.class == TrueClass || second.class == FalseClass || second.class == Fixnum || second.class == Float) && .class == String && !block_given? @j_del.java_method(:assertNotEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(first),::Vertx::Util::Utils.to_object(second),) return self end raise ArgumentError, "Invalid arguments when calling assert_not_equals(first,second,message)" end |
- (self) assert_not_null(expected = nil, message = nil)
Assert the
expected
argument is not null
. If the argument is null
, an assertion error is thrown
otherwise the execution continue.
68 69 70 71 72 73 74 75 76 77 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 68 def assert_not_null(expected=nil,=nil) if (expected.class == String || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && !block_given? && == nil @j_del.java_method(:assertNotNull, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(expected)) return self elsif (expected.class == String || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && .class == String && !block_given? @j_del.java_method(:assertNotNull, [Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(expected),) return self end raise ArgumentError, "Invalid arguments when calling assert_not_null(expected,message)" end |
- (self) assert_null(expected = nil, message = nil)
Assert the
expected
argument is null
. If the argument is not, an assertion error is thrown
otherwise the execution continue.
53 54 55 56 57 58 59 60 61 62 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 53 def assert_null(expected=nil,=nil) if (expected.class == String || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && !block_given? && == nil @j_del.java_method(:assertNull, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(expected)) return self elsif (expected.class == String || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && .class == String && !block_given? @j_del.java_method(:assertNull, [Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(expected),) return self end raise ArgumentError, "Invalid arguments when calling assert_null(expected,message)" end |
- (self) assert_true(condition = nil, message = nil)
Assert the specified
condition
is true
. If the condition is false
, an assertion error is thrown
otherwise the execution continue.
83 84 85 86 87 88 89 90 91 92 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 83 def assert_true(condition=nil,=nil) if (condition.class == TrueClass || condition.class == FalseClass) && !block_given? && == nil @j_del.java_method(:assertTrue, [Java::boolean.java_class]).call(condition) return self elsif (condition.class == TrueClass || condition.class == FalseClass) && .class == String && !block_given? @j_del.java_method(:assertTrue, [Java::boolean.java_class,Java::java.lang.String.java_class]).call(condition,) return self end raise ArgumentError, "Invalid arguments when calling assert_true(condition,message)" end |
- (::VertxUnit::Async) async(count = nil)
Create and returns a new async object, the returned async controls the completion of the test. This async operation
completes when the Async#complete is called
count
times.
The test case will complete when all the async objects have their Async#complete
method called at least once.
This method shall be used for creating asynchronous exit points for the executed test.
184 185 186 187 188 189 190 191 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 184 def async(count=nil) if !block_given? && count == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:async, []).call(),::VertxUnit::Async) elsif count.class == Fixnum && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:async, [Java::int.java_class]).call(count),::VertxUnit::Async) end raise ArgumentError, "Invalid arguments when calling async(count)" end |
- (Proc) async_assert_failure { ... }
Creates and returns a new async handler, the returned handler controls the completion of the test.
When the returned handler is called back with a failed result it completes the async operation.
When the returned handler is called back with a succeeded result it fails the test.
218 219 220 221 222 223 224 225 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 218 def async_assert_failure if !block_given? return ::Vertx::Util::Utils.to_async_result_handler_proc(@j_del.java_method(:asyncAssertFailure, []).call()) { |val| ::Vertx::Util::Utils.to_object(val) } elsif block_given? return ::Vertx::Util::Utils.to_async_result_handler_proc(@j_del.java_method(:asyncAssertFailure, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))) { |val| ::Vertx::Util::Utils.to_object(val) } end raise ArgumentError, "Invalid arguments when calling async_assert_failure()" end |
- (Proc) async_assert_success { ... }
Creates and returns a new async handler, the returned handler controls the completion of the test.
When the returned handler is called back with a succeeded result it invokes the
resultHandler
argument
with the async result. The test completes after the result handler is invoked and does not fails.
When the returned handler is called back with a failed result it fails the test with the cause of the failure.
Note that the result handler can create other async objects during its invocation that would postpone
the completion of the test case until those objects are resolved.
203 204 205 206 207 208 209 210 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 203 def async_assert_success if !block_given? return ::Vertx::Util::Utils.to_async_result_handler_proc(@j_del.java_method(:asyncAssertSuccess, []).call()) { |val| ::Vertx::Util::Utils.to_object(val) } elsif block_given? return ::Vertx::Util::Utils.to_async_result_handler_proc(@j_del.java_method(:asyncAssertSuccess, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_object(event)) }))) { |val| ::Vertx::Util::Utils.to_object(val) } end raise ArgumentError, "Invalid arguments when calling async_assert_success()" end |
- (Proc) exception_handler
@return an exception handler that will fail this context
228 229 230 231 232 233 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 228 def exception_handler if !block_given? return ::Vertx::Util::Utils.to_handler_proc(@j_del.java_method(:exceptionHandler, []).call()) { |val| ::Vertx::Util::Utils.to_throwable(val) } end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (void) fail - (void) fail(message) - (void) fail(cause)
This method returns an undefined value.
Throw a failure with the specified failurecause
.
165 166 167 168 169 170 171 172 173 174 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 165 def fail(param_1=nil) if !block_given? && param_1 == nil return @j_del.java_method(:fail, []).call() elsif param_1.class == String && !block_given? return @j_del.java_method(:fail, [Java::java.lang.String.java_class]).call(param_1) elsif param_1.is_a?(Exception) && !block_given? return @j_del.java_method(:fail, [Java::JavaLang::Throwable.java_class]).call(::Vertx::Util::Utils.to_throwable(param_1)) end raise ArgumentError, "Invalid arguments when calling fail(param_1)" end |
- (Object) get(key = nil)
Get some data from the context.
21 22 23 24 25 26 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 21 def get(key=nil) if key.class == String && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(key)) end raise ArgumentError, "Invalid arguments when calling get(key)" end |
- (Object) put(key = nil, value = nil)
Put some data in the context.
This can be used to share data between different tests and before/after phases.
33 34 35 36 37 38 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 33 def put(key=nil,value=nil) if key.class == String && (value.class == String || value.class == Hash || value.class == Array || value.class == NilClass || value.class == TrueClass || value.class == FalseClass || value.class == Fixnum || value.class == Float) && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:put, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(key,::Vertx::Util::Utils.to_object(value))) end raise ArgumentError, "Invalid arguments when calling put(key,value)" end |
- (Object) remove(key = nil)
Remove some data from the context.
42 43 44 45 46 47 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-unit/test_context.rb', line 42 def remove(key=nil) if key.class == String && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(key)) end raise ArgumentError, "Invalid arguments when calling remove(key)" end |