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
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
73
Beyond the Rails Way
mario_chavez
1
130
Elm, una mejor manera de hacer frontend
mario_chavez
0
250
Rediscovering ActiveRecord
mario_chavez
2
360
Intro to Elixir
mario_chavez
0
180
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
440
Pitch para Startups
mario_chavez
1
150
Understanding KPIs
mario_chavez
1
130
Logic Programming
mario_chavez
0
150
Other Decks in Technology
See All in Technology
私がブラウザを自作したくなった理由
supurazako
1
280
生成 AI の基礎 〜 サンプル実装で学ぶ基本原理
enakai00
7
4.6k
【GCC2026】TrueHDRIを用いたルックデブ環境とライティングテクニック
bandainamcostudios
PRO
0
230
英語が話せなくてもKubeConスタッフに参加した話
yusuke427
2
1.1k
AIのためのEthernet技術動向 (SerDes)
markunet
1
300
属人化を叩き割れ!「制作加速」と「安定化」の矛盾を打破する:8年目プロダクトが辿り着いた「ミスが起こり得ない」アセット制作フローの全貌
gree_tech
PRO
0
120
AI-DLC実践録_フルサイクル開発への挑戦
miyuc
0
360
RapidCopy2 Matrix I/Oエンジンによるファイルコピーソフトウェアの設計と実装
kengosawa2
1
280
20分でわかるセキュアAPI
nwiizo
2
320
AIにブラウザを触らせて、E2EテストをPlaywrightで書く
koji_kawamura
0
350
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
도구에서 동료까지: 10년차 AI 스타트업의 AI 적응기
inureyes
PRO
1
330
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
420
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
How to Talk to Developers About Accessibility
jct
2
520
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
950
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
280
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
30 Presentation Tips
portentint
PRO
1
370
Producing Creativity
orderedlist
PRO
348
40k
Side Projects
sachag
455
43k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
660
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