-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
202n 年を迎えて尚、 test-unit > rspec
なのでは?という再考と、Power Assert
は良いぞという話
#33
Comments
test-unit > rspec
なのでは?という再考と、power-assert
は良いぞという話
test-unit > rspec
なのでは?という再考と、power-assert
は良いぞという話test-unit > rspec
なのでは?という再考と、power-assert
は良いぞという話
[ci skip] ref: kachick/times_kachick#33
test-unit > rspec
なのでは?という再考と、power-assert
は良いぞという話test-unit > rspec
なのでは?という再考と、Power Assert
は良いぞという話
さて、大昔と比べて test-unit に増えてる機能は Power Assert だけではないわけで、 https://qiita.com/repeatedly/items/727b08599d87af7fa671 で紹介されてる rspec っぽい記法は知っては居るが、そもそもブロックを避けられるなら越したこと無いなと思ってるのであんま使う気になれないな・・・ https://www.clear-code.com/blog/2013/1/23.html データ駆動テスト自体は自分も好きなのだけれど、正直 test 数が増える事自体には別に意味を感じられず、each で回して assertion 一杯で良いのでは?と思ってしまう。 |
データ駆動テスト用の機能
|
とか言っといてなんだけど、「ちゃんと作る」時には、なんかそれなりの手順が必要そうな雰囲気だ。 https://github.com/test-unit/test-unit/blob/a2106658fe85e79478322e03a33f75977b82c911/lib/test/unit/assertions.rb#L19-L40 ##
# Test::Unit::Assertions contains the standard Test::Unit assertions.
# Assertions is included in Test::Unit::TestCase.
#
# To include it in your own code and use its functionality, you simply
# need to rescue Test::Unit::AssertionFailedError. Additionally you may
# override add_assertion to get notified whenever an assertion is made.
#
# Notes:
#
# * The message to each assertion, if given, will be propagated with the
# failure.
# * It is easy to add your own assertions based on assert_block().
#
# @example Example Custom Assertion
#
# def deny(boolean, message=nil)
# message = build_message(message, '<?> is not false or nil.', boolean)
# assert_block(message) do
# not boolean
# end
# end public
# Called whenever an assertion is made. Define this in classes
# that include Test::Unit::Assertions to record assertion
# counts.
#
# This is a public API for developers who extend test-unit.
#
# @return [void]
def add_assertion
end ふむふむ、なるほどね(わかってない) |
とかもそうだけど、 ruby 本家系?が大体 test-unit を好んでいるという印象も昔から合って(なぜ 標準添付の minitest を選ばないのかは、色々あるんだろう)、個人的には rails project 的なので無ければやっぱ test-unit 使っとくのが一番無難なんじゃないのかなとは思っているんだよなぁ しかし https://github.com/ruby/csv/pull/216/files では 求められる |
最近はあんま Ruby 触らないけど、触るときは大体 test-unit か minitest なので rspec 書かなくなってきた。薄い rspec が置いてあると仕様とか確かに読みやすいと思うけど、網羅性広いのとか共通化しだすと test 系のほうが楽な気がする。両方使ってもいいのでは。 |
https://github.com/ruby/test-unit-ruby-core/blob/7b20ceb51631e69471684ffe242a3e3f5e56c760/lib/envutil.rb 経由で使えるようになってた! |
TL;DR
test-unit
が最強ではないのか?binding.irb
とかbinding.pry
みたいな事を頻繁にテストコード中でやりたくなるぐらいだったら、 power-assert を使っておくのに良い場面だと思う。(が、少なくとも Ruby の 今の https://github.com/ruby/power_assert には色々制限もあるので、元々の twada さん が提唱した「なんでも PowerAssert」という事にはならないかなと思っている。むしろ部分的に使うべきと言うか。 )何についてか / About
ref: link, link
経緯 / History
結論 / Conclusion
The text was updated successfully, but these errors were encountered: