System Tests and Others

Learn to write tests for system testing and integration testing with Minitest.

In addition to ActiveSupport::TestCase, Rails provides some other subclasses of Minitest::TestCase that provide custom functionality. In most of these cases, the RSpec functionality we’ve already seen is built on top of these classes:

  • The ActionView::TestCase, ActionMailer::TestCase, and ActiveJob::TestCase: All these classes provide specific support similar to the RSpec support discussed in the chapter “Testing Rails Display Elements".

Let’s look at the system and integration tests because they are the ones Rails core uses most frequently.

Minitest system tests

In Minitest, the Rails core team recommendation is to use system tests and Capybara only when invoking a JavaScript runtime. In other cases, the team recommends using integration tests.

JavaScript integration testing with Minitest

We have one JavaScript test in our suite. Here’s what it looks like in Minitest. We need to specify that we’re using headless Chrome as our driver (the Rails default is Selenium with a visible browser):

Get hands-on with 1200+ tech skills courses.