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
A New Testing Framework Rgot
Search
ksss
December 12, 2015
Programming
0
1.2k
A New Testing Framework Rgot
Speech of RubyKaigi2015 LT
ksss
December 12, 2015
Tweet
Share
More Decks by ksss
See All by ksss
RaaP
ksss
0
430
Railsの型ファイル自動生成における課題と解決
ksss
4
4.2k
RBS generation framework using Rack architecture
ksss
0
6.8k
mrubyでruby/specを走らせてみた結果www
ksss
1
2.4k
Rubyに型があると便利か
ksss
4
4.5k
mruby hacking guide
ksss
7
1.8k
Other Decks in Programming
See All in Programming
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
420
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
390
役立つログに取り組もう
irof
26
8.6k
Java ジェネリクス入門 2024
nagise
0
600
カスタムしながら理解するGraphQL Connection
yanagii
1
1.2k
僕がつくった48個のWebサービス達
yusukebe
18
17k
Sidekiqで実現する 長時間非同期処理の中断と再開 / Pausing and Resuming Long-Running Asynchronous Jobs with Sidekiq
hypermkt
6
2.7k
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
360
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.2k
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
Featured
See All Featured
How GitHub (no longer) Works
holman
311
140k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
Building Your Own Lightsaber
phodgson
102
6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
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
Become a Pro
speakerdeck
PRO
24
5k
The Cult of Friendly URLs
andyhume
78
6k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
13
1.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Transcript
A New Testing Framework Rgot ksss RubyKaigi2015
! " ksss _ksss_
None
A New Testing Framework was born …
Rgot Ruby + Golang Testing ksss/rgot !
$ gem i rgot ksss/rgot ! ruby 2.0 ʙ
!? ksss/rgot !
Again? ksss/rgot !
Do We Have to Learning New Things? ksss/rgot !
Rgot is Translation from Golang Testing to Ruby ksss/rgot !
Incidentally You Can Learn Golang Testing! ksss/rgot !
Golang ksss/rgot ! package foo_test func TestFooBar(t *testing.T) { if
3 != (1 + 2) { t.Error("failed") } }
Rgot ksss/rgot ! module FooTest def test_foo(t) if 3 !=
(1 + 2) t.error("failed") end end end
Golang-ish ksss/rgot !
Golang ksss/rgot ! $ go test -v === RUN TestFoo
--- PASS: TestFoo (1.01s) === RUN TestBar --- PASS: TestBar (1.00s) === RUN TestBaz --- PASS: TestBaz (1.01s) PASS ok ksss/gotest 3.017s
Rgot ksss/rgot ! $ rgot -v === RUN test_foo ---
PASS: test_foo (1.01s) === RUN test_bar --- PASS: test_bar (1.00s) === RUN test_baz --- PASS: test_baz (1.01s) PASS ok RgotTest 3.042s
Golang ksss/rgot ! package foo_test func BenchmarkQux(b *testing.B) { for
i := 0; i < b.N; i++ { foo.Qux() } }
Rgot ksss/rgot ! module FooTest def benchmark_qux(b) i = 0
while i < b.n Foo.qux i += 1 end end end
Golang ksss/rgot ! package pow_test func BenchmarkPow(b *testing.B) { b.RunParallel(func(pb
*testing.PB) { for pb.Next() { math.Pow(1000.0, 1000.0) } }) }
Rgot ksss/rgot ! module PowTest def benchmark_pow(b) b.run_parallel do |pb|
while pb.next 1000.0 ** 1000.0 end end end end
Golang ksss/rgot ! $ go test -bench . -cpu 2,4
PASS BenchmarkPow-2 100000000 22.3 ns/op BenchmarkPow-4 100000000 12.5 ns/op ok github.com/pow_test 3.522s GOMAXPROCS
Rgot ksss/rgot ! $ rgot --bench . --cpu 2,4 --thread
2,4 PASS benchmark_pow-2(2) 25600000 74 ns/op benchmark_pow-2(4) 81920000 74 ns/op benchmark_pow-4(2) 81920000 39 ns/op benchmark_pow-4(4) 40960000 40 ns/op ok PowTest 13.603s process thread
Golang ksss/rgot ! package foo_test func ExampleFoo { fmt.Println(foo.Say()) //
Output: // foo }
Rgot ksss/rgot ! module FooTest def example_foo puts Foo.say #
Output: # foo end end
Golang ksss/rgot ! $ go test -v === RUN ExampleFoo
--- FAIL: ExampleFoo (0.00s) got: bar want: foo FAIL exit status 1 FAILgithub.com/ksss/gotest 0.005s
Rgot ksss/rgot ! $ rgot -v === RUN example_foo ---
FAIL: example_foo (0.00s) got: bar want: foo FAIL exit status 1 FAILRgotTest 0.001s
Thinking ksss/rgot !
Diversity ksss/rgot !
Testing before Benchmark ksss/rgot !
Testable Sample Code ksss/rgot !
Not Need /test or /spec Dir ksss/rgot !
ksss/rgot !
Short Class Name testing.M => Rgot::M testing.T => Rgot::T testing.B
=> Rgot::B ksss/rgot !
Zero Assert ksss/rgot !
t.error() ksss/rgot !
More Thinking ksss/rgot !
Assert Oriented v.s. Error log Oriented ksss/rgot !
Assert Oriented case ksss/rgot ! mimitest, test-unit, rspec, etc…
case ksss/rgot ! Error log Oriented
Error Report is Important ksss/rgot !
Precise errors are particularly important when the programmer seeing the
errors is not familiar with the code. #https://golang.org/doc/faq#assertions ksss/rgot !
Words ksss/rgot !
Words - assert - should - expect - must minitest,
test-unit, rspec, … ksss/rgot !
Words - want - got - failed - invalid Golang
testing package ksss/rgot !
Words (hypothesis) minitest, test_unit, rspec,… Golang testing package Hard Soft
ksss/rgot !
ksss/rgot !