What should I use for the testing framework [Rails]


For the time being, I released the application on AWS the other day, leaving the test and implementation of the detailed security part as an issue.

That's why I released it safely, but I still have to implement the test, so I investigated the test.

As a result of my research, I came to the conclusion that it is more efficient to learn RSpec first.

The contents of the investigation are listed below.

--What is a test? --What is the testing framework implemented in Rails? --A brief overview of the three testing frameworks found on the net ――What is the most popular testing framework?

What is a test?

In order for an application to run on a production server, the application's code must be working as specified and without defects (bugs).

Testing is the process of verifying that the application's code is working as specified and finding bugs.

By finding a bug, we fix (debug) it.

Reference: [https://ja.wikipedia.org/wiki/Software Testing](https://ja.wikipedia.org/wiki/%E3%82%BD%E3%83%95%E3%83%88 % E3% 82% A6% E3% 82% A7% E3% 82% A2% E3% 83% 86% E3% 82% B9% E3% 83% 88)

Testing framework

The tests are run on what is called a testing framework.

There are various testing frameworks used in Rails applications.

Below is a list of some testing frameworks, along with an overview and features.

Minitest overview

Minitest is a testing framework that comes standard with Ruby.

It comes standard so you can test it without having to add gems.

The documentation is available in the Rails Guides (https://railsguides.jp/testing.html) (English version).

Reference: https://railsguides.jp/testing.html

RSpec Overview

RSpec is a testing framework for Behavior-Driven Development tools for Ruby.

Documentation can be found at rspec-rails.

Reference: https://relishapp.com/rspec

test-unit overview

test-unit is an xUnit unit test framework for Ruby.

The documentation is available in Unit Testing Framework for Ruby.

Reference: https://test-unit.github.io/ja/index.html

What are the most popular testing frameworks?

I've found three, but for engineers, it's necessary to determine the amount of knowledge on the net and what the de facto standard is, and what is appropriate to use. With that said, I tried to find out which one is the most used under the following conditions.

--Qiita is the number of articles searched in the format of "Minitest tag: rails" --GitHub uses Ruby as the language and the number of repositories searched --Results as of writing (October 6, 2020).

Testing framework Qiita GitHub
Minitest 366 955
RSpec 2151 11306
test-unit 428 921

The table above isn't absolute, but RSpec seems to be the most used.

Certainly, I often see the word RSpec, so I was convinced.

What I still don't understand

The differences and features of each testing framework, what the BDD and xUnit systems are, etc. have not been clarified yet, but this time I will dig deeper into this detail and quit.

RSpec seems to be the most used testing framework, so I'd like to actually use it first and accumulate knowledge about what it looks like.

Even if you actually use all of them and compare them, it is inefficient.


So, it was a story that came to the conclusion that we will proceed with learning RSpec first.

Recommended Posts

What should I use for the testing framework [Rails]
[Java] What should I use for writing files?
After all, how should I use Rails callback?
I summarized the naming conventions for each Rails
What should I do to reload the updated Dockerfile?
[Rails] I don't know how to use the model ...
I summarized the collection framework.
What is the constructor for?
Why can I use the rails command installed with gem? ??
I tried to introduce Bootstrap 4 to the Rails 6 app [for beginners]
[Rails] I tried using the button_to method for the first time
What to do if you can't use the rails command
docker What should I do first? (Somehow I understand the shell, but ... for beginners at the level)
[Rails] What was the error message?
What I learned from studying Rails
I made a reply function for the Rails Tutorial extension (Part 1)
I tried the Java framework "Quarkus"
[Rails] I tried deleting the application
I made a reply function for the Rails Tutorial extension (Part 5):
Which class should I use to get the date and time in my Rails app (Time, DateTime, TimeWithZone)
I want you to use Enum # name () for the Key of SharedPreference
What is testing? ・ About the importance of testing
Change the default timezone for the rails app
[Rails] How to use the map method
What I learned through the swift teacher
Prepare the security check environment for Rails 6
Testing for Error Messages: Rails Tutorial Notes-Chapter 7
What is the model test code testing
What is the Facade pattern useful for?
Use the l method for time notation
I want you to use Scala as Better Java for the time being
I searched for a lightweight framework that answers the sudden "make it quickly"
I rewrote the Rails tutorial test with RSpec
Use [Rails] devise Guest user function (for portfolio)
[Rails] I tried to raise the Rails version from 5.0 to 5.2
The code I used to connect Rails 3 to PostgreSQL 10
What is the volatile modifier for Java variables?
I tried touching Docker for the first time
[Rails] How to use Gem'rails-i18n' for Japanese support
Use Java external library for the time being
Use pagy for pagination in your Rails app.
I specified the version and rails new, but for some reason the latest version is included ~
[Rails] I could use .sample when I wanted one record at random from the table.
For those who want to use MySQL for the database in the environment construction of Rails6 ~.