Ruby On Rails On Minitest - Zenspider

17d ago
9 Views
0 Downloads
8.43 MB
254 Pages
Last View : 10d ago
Last Download : n/a
Upload by : Halle Mcleod
Share:
Transcription

Ruby on Rails on MinitestRyan Davis, Seattle.rbRuby on Railson MinitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSetting ExpectationsIntroductory Talk.Very Little Code.Not going to teach testing or TDD.What & why, not how.218 Slides, 5.45 SPM.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWTF isminitest?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWhat is Minitest?Replacement for ruby 1.8’s test/unit.Originally 90 lines of code, only test/unit basics.Available as a gem, and ships with ruby 1.9.1 & up.Meant to be small, clean, and very fast.Now 1600 loc, unit, spec, benchmarks, mock/stub, plugins, etc.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb6 Parts of MinitestrunnerThe heart of the machineminitest/unitTDD APIminitest/specBDD APIminitest/mockSimple mocking APIminitest/prideIO pipelining exampleminitest/benchAbstract benchmark APIRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb2 Parts of MinitestrunnerThe heart of the machineminitest/unitTDD APIminitest/specBDD APIminitest/mockSimple mocking APIminitest/prideIO pipelining exampleminitest/benchAbstract benchmark APIRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbminitest/testRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest CasesareClassesRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTestsareMethodsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest Examplerequire "minitest/autorun"class TestThingy Minitest::Testdef test do the thingassert equal 42, Thingy.do the thingendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest Examplerequire "minitest/autorun"Simple Subclassclass TestThingy Minitest::Testdef test do the thingassert equal 42, Thingy.do the thingendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest Examplerequire "minitest/autorun"Simple Subclassclass TestThingy Minitest::Testdef test do the thingassert equal 42, Thingy.do the thingendendSimple MethodRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest Examplerequire "minitest/autorun"Simple Subclassclass TestThingy Minitest::Testdef test do the thingassert equal 42, Thingy.do the thingendendSimple MethodRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbPositive Assertionsassertassert kind ofassert respond toassert emptyassert matchassert sameassert equalassert nilassert send*assert in deltaassert operatorassert silent* assert in epsilon assert output* assert throws*assert includes assert predicate not in testunitassert instance ofRailsConf 2015, Atlanta, GAassert raises*11*no negative [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNegative Assertionsrefute refute kind of refute respond to refute empty refute matchrefute samerefute equalrefute nilrefute sendrefute in delta refute operator refute silentrefute in epsilon refute outputrefute throwsrefute includes refute predicate not in testunitrefute instance of RailsConf 2015, Atlanta, GArefute [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWhy all these extra assertions?They're more expressive!assert ! objrefute objassert collection.include? objassert includes obj, collectionout, err capture io dodo somethingendassert equal "output", outassert equal "", errassert output "output", "" dodo somethingendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbassert equal diffs:1) Failure:test failing simple(TestSimple) [example.rb:8]:Expected: 42Actual: 242) Failure:test failing complex(TestComplex) [example.rb:23]:--- expected [email protected]@ -22,7 22,7 @@"line 22","line 23","line 24",- "line 25", "something unexpected","line 26","line 27","line 28",RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbBut.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWhere isrefute raises?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSame place asrefute silent.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbrefute silentThis block of code must print something.What it is, I don't care.How is this assertion of value to anyone?Assert for the specific output you need.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbrefute silentThis block of code must print something.What it is, I don't care.How is this assertion of value to anyone?Assert for the specific output you need.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbrefute raisesThis block of code must do something.What it is, I don't care.How is this assertion of value to anyone?Assert for the specific result you need.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb“It's Useful”No it isn't.Implies side effects and/or return values have been checked.Or aren't important (always false—otherwise, why write the code?).Falsely bumps code coverage metrics.False sense of security.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb“It's More Expressive”No it isn't.Writing the test was the act of expression.It is an explicit contract in any test framework that unhandledexceptions are an error.The test's mere existence explicitly states:"there are no unhandled exceptions via these pathways".RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbI've been having thisargument for yearsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSome people willnever be convincedRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbStand BackRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbdef check everythingassert something output doassert nothing raised doassert some side effect doassert some response doyieldendendendendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbdef check everythingassert something output doassert nothing raised doassert some side effect doassert some response doyieldendend rprise Certified Available for RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRailsConf 2015, Atlanta, GARyan Davis, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbminitest/specRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTesting DSLRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest Casesare describe blocksRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTestsare it blocksRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSpec Examplerequire "minitest/autorun"describe Thingy doit "must do the thing" do(Thingy.do the thing).must equal 42endendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbButRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbIn RealityRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb describe blocksareClassesRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb it blocksareMethodsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSpec Examplerequire "minitest/autorun"describe Thingy doit "must do the thing" do(Thingy.do the thing).must equal 42endendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSpecs Transform:require "minitest/autorun"class TestThingy Minitest::Testdef test 0001 must do the thing(Thingy.do the thing).must equal 42endendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSpecs Transform:require "minitest/autorun"Simple Subclassclass TestThingy Minitest::Testdef test 0001 must do the thing(Thingy.do the thing).must equal 42endendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSpecs Transform:require "minitest/autorun"Simple Subclassclass TestThingy Minitest::Testdef test 0001 must do the thing(Thingy.do the thing).must equal 42endendSimple MethodRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSpecs Transform:require "minitest/autorun"Simple Subclassclass TestThingy Minitest::Testdef test 0001 must do the thing(Thingy.do the thing).must equal 42endendSimple MethodRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbPositive Expectationsmust bemust be within epsilonmust be close tomust equalmust be emptymust includemust be instance ofmust matchmust be kind ofmust output*must be nilmust raise*must be same asmust respond tomust be silent*must send*must be within deltamust throw*RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNegative Expectationswont bewont be within epsilonwont be close towont equalwont be emptywont includewont be instance ofwont matchwont be kind ofwont outputwont be nilwont raisewont be same aswont respond towont be silentwont sendwont be within deltawont throwRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbAll for Freemust equal is assert equalwont equal is refute equaletc.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbAdvanced TestingRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbRandomizationBaked InRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbPreventing TestOrder DependenciesRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbparallelize me!RailsConf 2015, Atlanta, [email protected] zenspider

std5lib6test spectesblesaeutor10rnequireProofofSuccetest ed urn up thetorrd etOsTefacizeomem,nRendegtcasWrite custom assertionsRaUsRyan Davis, Seattle.rbesRuby on Rails on MinitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbDesign RationaleRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbIt's Just Ruby RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLook! Ruby!require "minitest/autorun"class TestThingy Minitest::Testdef test do the thingassert equal 42, Thingy.do the thingendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLess is MoreRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbassert in deltadef assert in delta e, a, d 0.001, m niln (e - a).absmsg message(m) { ". failure message ." }assert delta n, msgendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbassert in deltadef assert in delta e, a, d 0.001, m niln (e - a).absmsg message(m) { ". failure message ." }assert delta n, msgmessage takes aendblock to defercalculation until anassertion failsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbassert in deltadef assert in delta e, a, d 0.001, m niln (e - a).absmsg message(m) { ". failure message ." }assert delta n, msgmessage takes aendsimple assertion is allthat is neededRailsConf 2015, Atlanta, GA51block to defercalculation until anassertion [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbassert in deltadef assert in delta e, a, d 0.001, m niln (e - a).absmsg message(m) { ". failure message ." }assert delta n, msgmessage takes aendsimple assertion is allthat is neededOnly 2 other methodsneed to be understood:assert (9) & message (6)RailsConf 2015, Atlanta, GA51block to defercalculation until anassertion [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbIndirection isthe EnemyRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbJust 2 Hopsmodule Minitest::Expectationdef must equal(*args)ctx.assert equal(*args)endendmodule Minitest::Assertionsdef assert equal exp, act, msg nilmsg message(msg, E) { diff exp, act }assert exp act, msgendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNo MagicAllowedRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbThriving Plugin lsminitest-matchersguard-minitestcapybara minitest nf 2015, Atlanta, GA55(& many more)@the zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbRails &MinitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTheOfficial Rails Stack uses MinitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbEach ReleaseRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbPeels backthe ll/303874154RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbEncouraging bettertesting practicesRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbPeelingonions 221935RailsConf 2015, Atlanta, GA61you [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbRight?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb(Hopefully)Not HereRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbRails 4.0minitest 4.xRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbImpact?ZeroRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbRails 4.1minitest 5.xRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbImpact?ZeroRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbRails 4.2random orderRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSome Impact?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbGood Thing !RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbFuture RailsShould track minitest.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbAs a Rails DevRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWhat doesall of thismean?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbHopefully.RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNothingRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbActiveSupport::TestCaseRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbBasic yThingyTestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbPer-test databasetransactionsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbFixtures# In fixtures/categories.ymlabout:name: About# In fixtures/articles.ymlone:title: Welcome to Rails!body: Hello world!category: aboutRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbDeclarative Formssetup do# .endteardown do# .endtest “test name” do# .endRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbExtra Assertionsassert differenceassert valid keysassert deprecatedassert nothing raisedRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWait? What?!?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbDon't Worry!def assert nothing raised(*args)yieldendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbDon't Worry!def assert nothing raised(*args)yieldendActualImplementationRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbUnit Testingrequire 'test helper'class ArticleTest ActiveSupport::TestCasetest "should not save article without title" doarticle Article.newrefute article.saveendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbActionController::TestCaseRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbBasic ctionController::TestCaseMyControllerTestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbActionsgetpostdeleteetcRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, f 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbAssertionsassert responseassert redirected toassert templateRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbFunctional Testingclass ArticlesControllerTest ActionController::TestCasetest "should get index" doget :indexassert response :successassert not nil assigns(:articles)endendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbActiveDispatch::IntegrationTestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, ionTestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbAssertionsTonsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbIntegration Testingclass UserFlowsTest ActionDispatch::IntegrationTesttest "login and browse site" dohttps!get "/login"assert response :successdavid users :davidpost via redirect "/login", username: david.username, password: david.passwordassert equal '/welcome', pathassert equal 'Welcome david!', flash[:notice]https! falseget "/articles/all"assert response :successassert assigns :articlesendendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, mlRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbVery SimpleRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbVery PowerfulRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLeveragesMinitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTestRandomizationRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbParallelizationRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbEnforce BetterTestingRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTroubleshootingRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbI want to useminitest, but Iprefer spec-style RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbSimpleRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbminitest-railsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbminitest-spec-railsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLets you do this:describe User dolet(:user) { User.create! . }it "does the thing to the stuff" douser.username.must match(/./)endendRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbI upgraded to rails4.2 and now I havefailuresRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbAKA:you broke all myshitRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNot as SimpleRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTest-OrderDependency BugRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbran: a, b, c passran: b, a, c failRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbEasy!RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb“But, I havehundreds of tests!”RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNot so EasyRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbminitest-bisectRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbHelps youisolate and debugrandom test failuresRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRailsConf 2015, Atlanta, GARyan Davis, [email protected] zenspider

Ruby on Rails on MinitestRailsConf 2015, Atlanta, GARyan Davis, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbI'm used to RSpec factory-girl this that kitchen sink everythingRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbA lot of stuffJust Works RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLook for pluginsin readme / gemsRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbMy Suggestion?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLess ComplicatedTestingRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTry ItRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbYou MightLike ItRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbChange Takes TimeRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbWhy useminitest?RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb“Why Test?”aka“It slows me down”RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbNot Going toBotherRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbLost CauseRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbI'd rather helpother peopleRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rb“Everyone UsesRSpec”RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbObviously NotRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbTheOfficial Rails Stack uses MinitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbDHH usesminitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbtenderlove usesminitestRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbJeff Casimir & cohortteach minitest atTuring SchoolRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbnokogiri, haml, god,newrelic rpm, sqlite3RailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbetcRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbFunctionalDifferences withRSpecRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbUnique Features of RSpecTest metadata &metadata filtering.Fancier expectations,negation, etc.Shared contexts &example groups.RailsConf 2015, Atlanta, GAImplicit subject,described class, etc.before(:all) &around(:each).Fancier mocking.Fancier [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbUnique Features of RSpecTest metadata &metadata filtering.Fancier expectations,negation, etc.Shared contexts &example groups.RailsConf 2015, Atlanta, GAImplicit subject,described class, etc.before(:all) &around(:each).Fancier mocking.Fancier reporting.141Basically, it's [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbUnique Features of MinitestUnit & Spec Style Testing.Über-Duper fast andlightweight.Easy to understandwhole library.minitest/pride.Benchmark tests.RailsConf 2015, Atlanta, GAFirst to randomizeparallelize me! &minitest/hellClean & easy pluginsystem.Smallest mock/[email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbUnique Features of MinitestUnit & Spec Style Testing.Über-Duper fast andlightweight.Easy to understandwhole library.minitest/pride.Benchmark tests.RailsConf 2015, Atlanta, GAFirst to randomizeparallelize me! &minitest/hellClean & easy pluginsystem.Smallest mock/stubSimple, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbUnique Features of MinitestUnit & Spec Style Testing.Über-Duper fast andlightweight.Easy to understandwhole library.minitest/pride.Benchmark tests.RailsConf 2015, Atlanta, GAFirst to randomizeparallelize me! &minitest/hellClean & easy pluginsystem.Smallest mock/stubframework.142Simple, Pragmaticand a bit [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbCognitivedifferences withRSpecRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbMyron MarstonRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbGreatComparisonRailsConf 2015, Atlanta, [email protected] zenspider

Ruby on Rails on MinitestRyan Davis, Seattle.rbI'm one of the RSpec developers, and have never used minitest, so take my biases intoaccount when reading this answer.By and large, RSpec's power comes from the fact that it reifies so many testing concepts intofirst class objects. Where Test::Unit and Minitest use simple methods for making assertions,RSpec uses first-class matcher objects that support negation, self-description and more.RSpec's examples are first-class objects that support rich metadata; minitest/spec compilesit blocks down into simple methods, which don't support the same sort of rich metadata.RSpec supports specifying shared behaviors using a first-class construct (shared examplegroups) that accepts arguments; w/ minitest you can use inheritance or a mixin to re-usetests, but it doesn't have the same sort of first-class support. RSpec has an explicit formatterAPI (and there are many third party formatters that use it); I'm not aware of minitest having thesame sort of first-class formatter API.As somebody who is constantly running tests and practicing TDD all day long, I find thepower RSpec gives me to be very useful. Many people find it to be overkill, though, and thereis an added cognitive cost to the extra abstractions.Here are some specific features RSpec has that I believe minitest lacks:hooks (note this is a power user feature of RSpec that should rarely beused; I've only used it on a few occasions in many years of using RSpec)before(:all)around(:each)hooksShared example groupsShared contextsRich metadata support that can be used to control which examples get run, whichexample groups shared contexts get included in, which example groups modules getmixed into and more.146RailsConf 2015, Atlanta,GAIntegrated support for a wide range of mocking features w/ rspec-mocks; Minitest::[email protected] zenspider

on Rails on Minitest2RubyAnswersRyan Davis, Seattle.rbI'm one of the RSpec developers, and have never used minitest, so take my biases intoaccount when reading this answer.By and large, RSpec's power comes from the fact that it reifies so many testing concepts intofirst class objects. Where Test::Unit and Minitest use simple methods for making assertions,RSpec uses first-class matcher objects that support negation, self-

Ruby on Rails on Minitest RailsConf 2015, Atlanta, GA Ryan Davis, Seattle.rb @the_zenspider Positive Assertions assert assert_empty assert_equal assert_in_delta assert_in_epsilon assert_includes assert_instance_of assert_kind_of assert_match assert_nil assert_operator assert_output* assert_predicate assert_raises* assert_respond_to assert_same