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
200
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
49
Beyond the Rails Way
mario_chavez
1
90
Elm, una mejor manera de hacer frontend
mario_chavez
0
220
Rediscovering ActiveRecord
mario_chavez
2
330
Intro to Elixir
mario_chavez
0
150
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
410
Pitch para Startups
mario_chavez
1
120
Understanding KPIs
mario_chavez
1
88
Logic Programming
mario_chavez
0
110
Other Decks in Technology
See All in Technology
ドキュメントはAIの味方!スタートアップのアジャイルを加速するADR
kawauso
3
470
TypeScript入門
recruitengineers
PRO
33
11k
DuckDB-Wasmを使って ブラウザ上でRDBMSを動かす
hacusk
1
130
ヒューリスティック評価を用いたゲームQA実践事例
gree_tech
PRO
0
330
絶対に失敗できないキャンペーンページの高速かつ安全な開発、WINTICKET × microCMS の開発事例
microcms
0
300
実運用で考える PGO
kworkdev
PRO
0
120
Browser
recruitengineers
PRO
6
1.9k
【 LLMエンジニアがヒューマノイド開発に挑んでみた 】 - 第104回 Machine Learning 15minutes! Hybrid
soneo1127
0
200
生成AI時代のデータ基盤
shibuiwilliam
1
820
現場が抱える様々な問題は “組織設計上” の問題によって生じていることがある / Team-oriented Organization Design 20250827
mtx2s
7
67k
見てわかるテスト駆動開発
recruitengineers
PRO
6
2.2k
ソフトウェア エンジニアとしての 姿勢と心構え
recruitengineers
PRO
22
12k
Featured
See All Featured
BBQ
matthewcrist
89
9.8k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
500
How GitHub (no longer) Works
holman
315
140k
4 Signs Your Business is Dying
shpigford
184
22k
The World Runs on Bad Software
bkeepers
PRO
70
11k
Thoughts on Productivity
jonyablonski
69
4.8k
Typedesign – Prime Four
hannesfritz
42
2.8k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
We Have a Design System, Now What?
morganepeng
53
7.8k
Automating Front-end Workflow
addyosmani
1370
200k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
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