LoginSignup
1
1

More than 5 years have passed since last update.

Rubyで、D言語風にassertionを直書きする簡易unit test

Last updated at Posted at 2013-08-14

まあ、なんと云ふか、めんどくさかったりするし、D言語のunittest blockが羨ましかったりするし(〃l _ l)
assertion丈使ひたいので、Module: Test::Unit::Assertions (Ruby 2.0)を読み込む。
下記を読めば解る。

$DEBUG = true

# @param test_name [String]
def unittest test_name, &proc
  if $DEBUG
    proc.call
    puts "#{test_name} ok."
  end
end
if $DEBUG
  require 'test/unit/assertions'
  include Test::Unit::Assertions
end

unittest 'test of test' do
  assert_equal 2, 1 + 1
end

cf. Rubyで、D言語風にassertionを直書きする簡易unit test - c4se記:さっちゃんですよ☆

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1