Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A New Testing Framework Rgot

ksss
December 12, 2015

A New Testing Framework Rgot

Speech of RubyKaigi2015 LT

ksss

December 12, 2015
Tweet

More Decks by ksss

Other Decks in Programming

Transcript

  1. Rgot ksss/rgot ! module FooTest def test_foo(t) if 3 !=

    (1 + 2) t.error("failed") end end end
  2. 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
  3. 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
  4. Rgot ksss/rgot ! module FooTest def benchmark_qux(b) i = 0

    while i < b.n Foo.qux i += 1 end end end
  5. 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) } }) }
  6. 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
  7. 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
  8. 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
  9. Rgot ksss/rgot ! $ rgot -v === RUN example_foo ---

    FAIL: example_foo (0.00s) got: bar want: foo FAIL exit status 1 FAILRgotTest 0.001s
  10. 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 !
  11. Words - assert - should - expect - must minitest,

    test-unit, rspec, … ksss/rgot !
  12. Words - want - got - failed - invalid Golang

    testing package ksss/rgot !