Module: L::Test

Defined in:
lib/rub/l/test.rb

Overview

Testing.

This testing is powered by Minitest. Look up the docs for that.

All test are defined as regular Minitest tests and they will be automatically picked up and have tags created for them.

When defining the test class there will be an additional method Minitest::Runnable#rub_add_dependency that will allow the test to depend on any target. Therefore you can ensure that what you are testing has been built.

Examples:

Defining dependencies.


Minitest::Test
  rub_add_dependancy $myexe # Ensure $myexe will be available when test are run.

  def test_help
    c = R::Command.new [$myexe, '--help']
    c.run

    assert c.success?, 'Help exited with a good status code'
  end
end

Defined Under Namespace

Classes: Reporter, TargetTest, TargetTestCase, TargetTestExecutable

Class Method Summary collapse

Class Method Details

.external(cmd, name) ⇒ Object



249
250
251
252
253
254
255
# File 'lib/rub/l/test.rb', line 249

def self.external(cmd, name)
  t = TargetTestExecutable.new
  t.add_cmd cmd
  t.output << name
  
  t.register
end

.make_test(klass) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/rub/l/test.rb', line 94

def self.make_test(klass)
  @tests ||= {}

  sklass = klass.to_s
  if sklass =~ /^Test/ 
    name = sklass
             .gsub(/(?<=[a-z0-9])([A-Z])/, '-\1')
             .gsub(/(?<=[^0-9])([0-9])/, '-\1')
             .gsub('_', '-')
             .downcase.to_sym
    #pp name
    
    @tests[name] ||= TargetTestCase.new(klass, name)
  end
end