Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Conociendo Minitest
Search
Mario Alberto Chávez
July 11, 2013
Technology
0
190
Conociendo Minitest
Introducción básica a Minitest, la librería de pruebas estándar desde Ruby 1.9
Mario Alberto Chávez
July 11, 2013
Tweet
Share
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
46
Beyond the Rails Way
mario_chavez
1
68
Elm, una mejor manera de hacer frontend
mario_chavez
0
190
Rediscovering ActiveRecord
mario_chavez
2
310
Intro to Elixir
mario_chavez
0
130
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
360
Pitch para Startups
mario_chavez
1
100
Understanding KPIs
mario_chavez
1
66
Logic Programming
mario_chavez
0
91
Other Decks in Technology
See All in Technology
フロントエンド メタフレームワーク 選定の際に考えたこと
yuppeeng
0
330
物価高なラスベガスでの過ごし方
zakky
0
470
SREの前に
nwiizo
9
1.3k
Product Engineer Night #6プロダクトエンジニアを育む仕組み・施策
hacomono
PRO
1
510
AWS re:Inventを徹底的に楽しむためのTips / Tips for thoroughly enjoying AWS re:Invent
yuj1osm
1
660
AWS パートナー企業でテクニカルサポートに従事して 3年経ったので思うところをまとめてみた
kazzpapa3
1
170
Forget efficiency – Become more productive without the stress
ufried
0
190
End of Barrel Files: New Modularization Techniques with Sheriff
rainerhahnekamp
0
210
最速最小からはじめるデータプロダクト / Data Product MVP
amaotone
5
780
ZOZOTOWNでの推薦システム活用事例の紹介
f6wbl6
0
230
VPC間の接続方法を整理してみた #自治体クラウド勉強会
non97
1
1k
ジョブマッチングサービスにおける相互推薦システムの応用事例と課題
hakubishin3
2
520
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Code Review Best Practice
trishagee
64
17k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Rails Girls Zürich Keynote
gr2m
93
13k
What's in a price? How to price your products and services
michaelherold
243
12k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Facilitating Awesome Meetings
lara
49
6.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
How to Ace a Technical Interview
jacobian
275
23k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Transcript
Minitest Mario A Chávez @mario_chavez
¿Quién prueba sus aplicaciones?
¿Quién prueba sus aplicaciones de forma automática?
- Test::Unit - RSpec -Minitest
Incluido como librería estándar desde Ruby 1.9
Test::Unit es historia, Minitest es compatible
Rspec bloated!
Minitest es pequeño y rápido, fácil de extender
Minitest es Ruby!
require 'minitest/autorun' class TeaTest < Minitest::Test def test_green_tea_temperature hot_tea =
Tea.new :green assert(hot_tea.temperature == 150) end end
require 'minitest/autorun' class TeaTest < Minitest::Test def test_green_tea_temperature hot_tea =
Tea.new :green assert_equal 150, hot_tea.temperature end end
Pero me gusta mas la sintaxis Spec!
require 'minitest/autorun' describe Tea do describe ‘Green tea’ do subject
{ Tea.new :green } it ‘temperature should be right’ do subject.temperature.must_equal 150 end end end
¿Qué? ¿doble “describe”? Vamos a extender Minitest
class Minitest::Spec class << self alias :context :describe end end
require 'minitest/autorun' describe Tea do context ‘Green tea’ do subject
{ Tea.new :green } it ‘temperature should be right’ do subject.temperature.must_equal 150 end end end
Matchers personalizados
require 'minitest/assertions' module Minitest::Assertions def assert_include(expected, actual) expected.is_a?(Enumerable) && expected.include?(actual)
end end require 'minitest/autorun' class TeaTest < Minitest::Test def test_available_teas_include_green teas = [:camomille, :green] assert_include teas, :green end end
require 'minitest/spec' module Minitest::Expectations Enumerable.infect_an_assertion :assert_inclu de, :must_include end require
'minitest/autorun' describe Tea do it 'available teas include green' do teas = [:camomile, :green] teas.must_include :green end end
Múltiples reporters
$ ruby minitest.rb -v Run options: -v --seed 58567 #
Running tests: Tea::Green tea#test_0001_temperature should be right = 0.00 s = . TeaTest#test_green_tea_temperature = 0.00 s = . Finished tests in 0.000986s, 2028.3976 tests/s, 2028.3976 assertions/s. 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
$ ruby minitest.rb Run options: --seed 36590 # Running: .
Finished in 0.001162s, 860.5852 runs/s, 0.0000 assertions/s. $ ruby minitest.rb -p Run options: -p --seed 8992 # Running: . Fabulous run in 0.001219s, 820.3445 runs/ s, 0.0000 assertions/s.
Minitest ejecuta las pruebas de forma aleatoria
También las puede ejecutar de forma paralela
Incluye: - Benchmark - Mocks -Stubs
Rails 4 usa Minitest con sintaxis de Test::Unit
Recursos •Repo de Git: https://github.com/seattlerb/minitest •Guía: http://mattsears.com/articles/2011/12/10/ minitest-quick-reference •Minitest-rails: https://github.com/blowmage/
minitest-rails •Como probar Rails con Minitest: http:// blog.crowdint.com/2013/06/14/testing-rails-with- minitest.html
Gracias Mario A Chávez @mario_chavez