Good evening. Today's topic is a test. There are some tests called Rails and I would like to summarize their features.
There are two tests to cover today. ● Minitest ● RSpec There are two. I was reading the Rails Tutorial and the book Ruby for professionals, both of which featured Minitest.
However, in my actual work I use RSpec I would like to know the characteristics of both, and I would like to summarize today.
Minitest Since minitest is installed with Ruby, no special setup is required, and it is a test framework that is included by default in Ruby on Rails. And that. In fact, you can use it just by writing Minitest with require (easy!)
Other features ● Shorter load time than RSpec ● Has the minimum required functions (added by plug-in) ● If you understand Ruby grammar, you will be ready to learn ● Validation methods are assert_equal A, B ● Be careful of duplicate class names and method names ● Not very suitable for writing elaborate code (difficult to analyze) ● Faster than RSpec
It seems that the above features can be mentioned. I did study, but I think I could understand it easily. Maybe it was because the syntax is the same as Ruby ...
RSpec RSpec is a framework that uses a domain-specific language (DSL). In other words, it's a programming language dedicated to testing. Other features
● You need to learn DSL (I said this above) ● Many default functions ● The validation method is expect (B) .to eq A or B.must_equal A ● Test naming is relatively free ● High maintainability ● Slow compared to Minitest
It's a little hard to study from 1 again ... lol But there are various merits.
I don't think there is an answer to this (I don't know) Comparing each, it seems that RSpec is used more in the field. Isn't it one of the reasons why RSpec is chosen in the field because it is more versatile and convenient?
I see. It was Tanji. I'm using this in practice, so I have to study for the time being, rather than motivation I wonder why I'm using this test framework I think that those who study from there will enjoy studying.
So I would like to study RSpec for the first time. I might also write an article about RSpec.
That's it for today.
** 94 days to become a full-fledged engineer **
Recommended Posts