Module: Inferno::DSL::Results

Included in:
Entities::TestGroup, Entities::TestSuite
Defined in:
lib/inferno/dsl/results.rb

Overview

This module contains methods to set test results.

Instance Method Summary collapse

Instance Method Details

#omit(message = '') ⇒ void

This method returns an undefined value.

Halt execution of the current test and mark it as omitted. This method can also take a block with an assertion, and if the assertion fails, the test will omit rather than fail. The message parameter is ignored if a block is provided.

Examples:

if behavior_does_not_need_to_be_tested?
  omit('Behavior does not need to be tested.')
end

omit do
  assert false, 'This test will omit rather than fail'
end

Parameters:

  • message (String) (defaults to: '')


73
74
75
76
77
78
79
# File 'lib/inferno/dsl/results.rb', line 73

def omit(message = '')
  raise Exceptions::OmitException, message unless block_given?

  yield
rescue Exceptions::AssertionException => e
  raise Exceptions::OmitException, e.message
end

#omit_if(test, message = '') ⇒ void

This method returns an undefined value.

Halt execution of the current test and mark it as omitted if a condition is true.

Parameters:

  • test (Boolean)
  • message (String) (defaults to: '')

Raises:



87
88
89
# File 'lib/inferno/dsl/results.rb', line 87

def omit_if(test, message = '')
  raise Exceptions::OmitException, message if test
end

#pass(message = '') ⇒ void

This method returns an undefined value.

Halt execution of the current test and mark it as passed.

Parameters:

  • message (String) (defaults to: '')

Raises:



9
10
11
# File 'lib/inferno/dsl/results.rb', line 9

def pass(message = '')
  raise Exceptions::PassException, message
end

#pass_if(test, message = '') ⇒ void

This method returns an undefined value.

Halt execution of the current test and mark it as passed if a condition is true.

Parameters:

  • test (Boolean)
  • message (String) (defaults to: '')

Raises:



19
20
21
# File 'lib/inferno/dsl/results.rb', line 19

def pass_if(test, message = '')
  raise Exceptions::PassException, message if test
end

#skip(message = '') ⇒ void

This method returns an undefined value.

Halt execution of the current test and mark it as skipped. This method can also take a block with an assertion, and if the assertion fails, the test will skip rather than fail. The message parameter is ignored if a block is provided.

Examples:

if some_precondition_not_met?
  skip('Some precondition was not met.')
end

skip do
  assert false, 'This test will skip rather than fail'
end

Parameters:

  • message (String) (defaults to: '')


39
40
41
42
43
44
45
# File 'lib/inferno/dsl/results.rb', line 39

def skip(message = '')
  raise Exceptions::SkipException, message unless block_given?

  yield
rescue Exceptions::AssertionException => e
  raise Exceptions::SkipException, e.message
end

#skip_if(test, message = '') ⇒ void

This method returns an undefined value.

Halt execution of the current test and mark it as skipped if a condition is true.

Parameters:

  • test (Boolean)
  • message (String) (defaults to: '')

Raises:



53
54
55
# File 'lib/inferno/dsl/results.rb', line 53

def skip_if(test, message = '')
  raise Exceptions::SkipException, message if test
end

#wait(identifier:, message: '', timeout: 300) ⇒ void

This method returns an undefined value.

Halt execution of the current test and wait for execution to resume.

Examples:

resume_test_route :get, '/launch' do
  request.query_parameters['iss']
end

test do
  input :issuer
  receives_request :launch

  run do
    wait(
      identifier: issuer,
      message: "Wating to receive a request with an issuer of #{issuer}"
    )
  end
end

Parameters:

  • identifier (String)

    An identifier which can uniquely identify this test run based on an incoming request. This is necessary so that the correct test run can be resumed.

  • message (String) (defaults to: '')
  • timeout (Integer) (defaults to: 300)

    Number of seconds to wait for an incoming request

Raises:

See Also:



117
118
119
120
121
122
# File 'lib/inferno/dsl/results.rb', line 117

def wait(identifier:, message: '', timeout: 300)
  identifier(identifier)
  wait_timeout(timeout)

  raise Exceptions::WaitException, message
end