aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit/testing.rake
blob: 486446b463c6b01a8f21863cc44b1f3c46915152 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
gem "minitest"
require "minitest"
require_relative "minitest_plugin"

task default: :test

desc "Runs all tests in test folder except system ones"
task :test do
  $: << "test"

  if ENV.key?("TEST")
    Minitest.rake_run([ENV["TEST"]])
  else
    Minitest.rake_run(["test"], ["test/system/**/*"])
  end
end

namespace :test do
  task :prepare do
    # Placeholder task for other Railtie and plugins to enhance.
    # If used with Active Record, this task runs before the database schema is synchronized.
  end

  task run: %w[test]

  desc "Run tests quickly, but also reset db"
  task db: %w[db:test:prepare test]

  ["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|
    task name => "test:prepare" do
      $: << "test"
      Minitest.rake_run(["test/#{name}"])
    end
  end

  task generators: "test:prepare" do
    $: << "test"
    Minitest.rake_run(["test/lib/generators"])
  end

  task units: "test:prepare" do
    $: << "test"
    Minitest.rake_run(["test/models", "test/helpers", "test/unit"])
  end

  task functionals: "test:prepare" do
    $: << "test"
    Minitest.rake_run(["test/controllers", "test/mailers", "test/functional"])
  end

  desc "Run system tests only"
  task system: "test:prepare" do
    $: << "test"
    Minitest.rake_run(["test/system"])
  end
end