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
45
Beyond the Rails Way
mario_chavez
1
67
Elm, una mejor manera de hacer frontend
mario_chavez
0
170
Rediscovering ActiveRecord
mario_chavez
2
300
Intro to Elixir
mario_chavez
0
120
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
320
Pitch para Startups
mario_chavez
1
86
Understanding KPIs
mario_chavez
1
60
Logic Programming
mario_chavez
0
85
Other Decks in Technology
See All in Technology
LINEヤフーのウェブアクセシビリティ
lycorptech_jp
PRO
2
160
データ分析力を高めるSQL研修サービス『SQL Everyone』
hikarut
1
390
Deno で作る快適な “as Code” プラットフォーム – TSKaigi 2024
pizzacat83
4
310
Real World Type Puzzle and Code Generation
yukukotani
4
630
生成AIと産業向けソフトウェアの自動生成 〜 ハノーバーメッセ2024より〜
kioto
2
420
Kaggleで学ぶ系列データのための深層学習モデリング
yu4u
7
1.7k
20240509 CloudWatch でいろいろなものを監視してみよう
masaruogura
1
120
LLM評価の落とし穴~開発者目線で気をつけるポイント~
rishigami
11
3.2k
Cloudflare WorkersがPythonに対応したので試してみた
miura55
0
190
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
12
7.9k
iThome2024 Wailing Wall of Enterprise Security
notsurprised
0
280
スクラムに出会って「できた」を実感できるようになってきた話 / Scrum makes me feel like I can do it
yayoi_dd
2
110
Featured
See All Featured
Optimizing for Happiness
mojombo
370
69k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
What's new in Ruby 2.0
geeforr
338
31k
Atom: Resistance is Futile
akmur
260
25k
Building Applications with DynamoDB
mza
88
5.7k
GraphQLの誤解/rethinking-graphql
sonatard
56
9.3k
The Language of Interfaces
destraynor
151
23k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
Infographics Made Easy
chrislema
238
18k
Fireside Chat
paigeccino
22
2.7k
Building an army of robots
kneath
300
41k
Designing with Data
zakiwarfel
96
4.8k
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