Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5.1 run system tests and normal tests with one command

Tags:

In Rails 5.1, you can do bin/rails test to run normal tests, and bin/rails test:system. What is the Rails sanctioned way of running both at the same time?

like image 818
chrismanderson Avatar asked Aug 21 '17 13:08

chrismanderson


People also ask

How do I run unit tests in Rails?

We can run all of our tests at once by using the bin/rails test command. Or we can run a single test file by passing the bin/rails test command the filename containing the test cases. This will run all test methods from the test case.

How do you run a Minitest?

Setting Up Minitest. To run a Minitest test, the only setup you really need is to require the autorun file at the beginning of a test file: require 'minitest/autorun' . This is good if you'd like to keep the code small. A better way to get started with Minitest is to have Bundler create a template project for you.

What is Rails integration test?

While unit tests make sure that individual parts of your application work, integration tests are used to test that different parts of your application work together. They are normally used to test at least the most important workflows of applications.


2 Answers

bin/rails test:system test

Specifying test:system before test will run both system and ordinary tests. The opposite order will only run the ordinary tests however.

like image 180
Eric Mathison Avatar answered Sep 26 '22 20:09

Eric Mathison


rails test:all (Rails 6.1+)

Rails 6.1 introduces a new command - rails test:all.

It runs all test files in the test directory, including system tests.

Here is a link to PR. And also a link to the docs (please, scroll down to yellow box).

like image 28
Marian13 Avatar answered Sep 25 '22 20:09

Marian13