Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
52
Beyond the Rails Way
mario_chavez
1
98
Elm, una mejor manera de hacer frontend
mario_chavez
0
230
Rediscovering ActiveRecord
mario_chavez
2
330
Intro to Elixir
mario_chavez
0
160
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
410
Pitch para Startups
mario_chavez
1
130
Understanding KPIs
mario_chavez
1
98
Logic Programming
mario_chavez
0
120
Other Decks in Technology
See All in Technology
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.2k
adk-samples に学ぶデータ分析 LLM エージェント開発
na0
3
930
Active Directory 勉強会 第 6 回目 Active Directory セキュリティについて学ぶ回
eurekaberry
10
3.9k
LangChain v1.0にトライ~ AIエージェントアプリの移行(v0.3 → v1.0) ~
happysamurai294
0
110
Eight Engineering Unit 紹介資料
sansan33
PRO
0
5.6k
機械学習を「社会実装」するということ 2025年冬版 / Social Implementation of Machine Learning November 2025 Version
moepy_stats
4
880
一億総業務改善を支える社内AIエージェント基盤の要諦
yukukotani
5
2k
段階的に進める、 挫折しない自宅サーバ入門
yu_kod
4
1.8k
生成AIシステムとAIエージェントに関する性能や安全性の評価
shibuiwilliam
2
260
雲勉LT_Amazon Bedrock AgentCoreを知りAIエージェントに入門しよう!
ymae
2
230
Codeer.LowCode.Blazor 紹介と成長録
wadawada
0
110
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
Featured
See All Featured
KATA
mclloyd
PRO
32
15k
How GitHub (no longer) Works
holman
316
140k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
680
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Speed Design
sergeychernyshev
33
1.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Building Applications with DynamoDB
mza
96
6.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
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