System Tests and Others
Learn to write tests for system testing and integration testing with Minitest.
We'll cover the following
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
ActionDispatch::SystemTestCase
: The parent class for system tests, which we saw in the chapter “Integration Testing with Capybara and Cucumber".
- The
ActionDispatch::IntegrationTest
: This is wrapped by RSpec request specs, as seen in the chapter “Testing Rails Display Elements”.
- The
ActionView::TestCase
,ActionMailer::TestCase
, andActiveJob::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 1400+ tech skills courses.