27
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

railsで任意にminitestを実行する方法

Posted at
lib/sample.rb
class Sample
  def initialize(msg)
    @msg = msg
  end

  def say
    @msg
  end

  def scream
    @msg.to_s.upcase.to_sym
  end
end
test/sample_test.rb
require 'test_helper'
require 'sample'

class SampleTest < ActiveSupport::TestCase 
  setup do
    @sample = Sample.new :hello
  end

  test 'sample 1' do
    assert_equal @sample.say, :hello
  end

  test 'sample 2' do
    assert_equal @sample.scream, :HELLO
  end
end
  • ファイル単位で実行する場合
$ rake test TEST=test/sample_test.rb
  • ブロック単位で実行する場合
$ rake test TEST=test/sample_test.rb TESTOPTS="--name=test_sample_2"
27
19
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
27
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?