Upload
bankfacil
View
122
Download
2
Embed Size (px)
Citation preview
MinitestRaphael Monteiro
Bankfacil
18/02/2015
Summary
● What is Minitest?● Minitest vs Rspec● Main assertions (syntax)● Reasons to use Minitest● Minitest into Rails● Minitest into Bankfacil● Further...
What is Minitest?
Minitest provides a complete suite of testing facilities.● minitest/unit● minitest/spec● minitest/benchmark● minitest/mock● minitest/pride
Minitest vs Rspec● "rspec is a testing DSL. minitest is ruby." - Adam
Hawkins, "Bow Before Minitest"● "Rspec is not about testing - it's about
documentation. That's why I prefer it" - Rahoul Baruah
Main assertions (syntax)● stub e mock
test 'execute' do
mock = Minitest::Mock.new
LeadToBkfApplicationCreator.stub(:new, mock,
lead_icarros) do
mock.expect(:create, true)
@ruler.execute(lead_icarros)
end
assert mock.verify
end
● more ex:
Reasons to use minitest
● Faster and lighter than Rspec● It is Ruby, no magic● Random & parallel tests● It is part of Ruby and Rails
Minitest into Rails● Since version 1.9, Ruby provides Minitest● test folder● setup and teardown methods● fixtures
# lo & behold! I am a YAML comment!david: name: David Heinemeier Hansson birthday: 1979-10-15 profession: Systems development
● rake test
Minitest into Bankfacil
● auto_financing project● assertions not spec● minitest-focus● minitest-reporters
class MyTest < MiniTest::Unit::TestCase
def test_unrelated; ...; end
focus
def test_method; ...; end # only
this one will run
def test_method_edgecase; ...; end
end
Further...● Official website: https://github.com/seattlerb/minitest● Ruby on Rails guides: http://guides.rubyonrails.org/v3.2.13/testing.html● Bow Before Minitest by Adam Hawkins: https://speakerdeck.
com/ahawkins/bow-before-minitest● RubyInside: http://www.rubyinside.com/dhh-offended-by-rspec-debate-4610.
html● Minitest Quick Reference: http://www.mattsears.
com/articles/2011/12/10/minitest-quick-reference● 7 Reasons I’m sticking with minitest: http://brandonhilkert.com/blog/7-reasons-
why-im-sticking-with-minitest-and-fixtures-in-rails/● 7 Reasons I love minitest: https://blog.engineyard.com/2014/seven-reasons-i-
love-minitest