Class: VertxUnit::TestContext
- Inherits:
-
Object
- Object
- VertxUnit::TestContext
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/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
Create and returns a new async object, the returned async controls the completion of the test.
-
- (void) fail(message = nil)
Throw a failure with the specified failure message.
-
- (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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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
Create and returns a new async object, the returned async controls the completion of the test. Calling the
Async#complete completes the async operation.
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.
177 178 179 180 181 182 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 177 def async if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:async, []).call(),::VertxUnit::Async) end raise ArgumentError, "Invalid arguments when calling async()" end |
- (void) fail(message = nil)
This method returns an undefined value.
Throw a failure with the specified failuremessage
.
161 162 163 164 165 166 167 168 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 161 def fail(=nil) if !block_given? && == nil return @j_del.java_method(:fail, []).call() elsif .class == String && !block_given? return @j_del.java_method(:fail, [Java::java.lang.String.java_class]).call() end raise ArgumentError, "Invalid arguments when calling fail(message)" end |
- (Object) get(key = nil)
Get some data from the context.
21 22 23 24 25 26 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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-aggregator/modules/vertx-unit/src/main/resources/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 |