Files
mapknitter/lib/tasks/test_unit.rake
Sasha Boginsky 6ae5c23a9b Restructure rake test task runner (#380)
* add a mysql setup file

* Squash commits
2019-03-25 10:58:22 -04:00

112 lines
4.4 KiB
Ruby

# ==================== #
# HOW TO RUN #
# You can find all rake tasks, both those that come built-in with rake / rails and custom created ones,
# by running `rake --tasks`. Note you might need to set up repo configurations before you are able to run this.
# `rake --tasks`, shows two columns: the name of the rake task (functions as the CLI command to run the task) and the
# description (what the task does). All the tasks created in this file start with "Autotask" in the description
# for easy reference. You can also find the commands (or command patterns for collections) commented above their respective tasks below.
# TEST STRUCTURE #
# Currently, you can
# 1) run all unit, functional, and integration tests together.
# 2) run only unit, functional, or integration tests (files within the corresponding folder can be run concurrently or one a time).
# 3) Last, you can run separate test files within the unit, functional, and integration test folders.
# If proper naming convention is followed, tasks are autogenerated for individual testing files added to the unit, functional, and
# integration folders (see creation of 'COMPUTE' arrays below).
# ==================== #
namespace :test do
# command: rake test:all
# run unit, functional, and integration test folders (one folder at a time, in the order indicated in the pattern below)
Rake::TestTask.new do |t|
t.name = "all"
t.description = "Autotask - run unit, functional, and integration tests"
t.libs << "test"
t.pattern = FileList["test/unit/*_test.rb", "test/functional/*_test.rb", "test/integration/*_test.rb"]
t.warning = false
t.verbose = true
end
# command pattern: rake test:unit_test_file.rb
# autogenerates a rake task for every test file added to test/unit
COMPUTE_UNIT_TASKS = []
Dir.glob("test/unit/*_test.rb").each do |task|
collection = task.gsub(/test\/unit\//, "")
Rake::TestTask.new(:"#{collection}") do |t|
t.libs << "test"
t.description = "Autotask - run unit tests - #{collection}"
t.pattern = FileList["test/unit/#{collection}"]
t.warning = false
t.verbose = true
end
COMPUTE_UNIT_TASKS << "#{collection}"
end
# command: rake test:unit
# run all unit test files (one file at a time in alphabetical order)
desc "Autotask - run unit tests"
task :unit => COMPUTE_UNIT_TASKS
# command: rake test:unit_parallel
# run all unit test files concurrently (one file at a time, order is not guaranteed)
desc "Autotask - run unit tests in parallel"
multitask :unit_parallel => COMPUTE_UNIT_TASKS
# command pattern: rake test:functional_test_file.rb
# autogenerates a rake task for every test file added to test/functional
COMPUTE_FUNCTIONAL_TASKS = []
Dir.glob("test/functional/*_test.rb").each do |task|
collection = task.gsub(/test\/functional\//, "")
Rake::TestTask.new(:"#{collection}") do |t|
t.libs << "test"
t.description = "Autotask - run functional tests - #{collection}"
t.pattern = FileList["test/functional/#{collection}"]
t.warning = false
t.verbose = true
end
COMPUTE_FUNCTIONAL_TASKS << "#{collection}"
end
# command: rake test:functional
# run all functional test files
desc "Autotask - run functional tests"
task :functional => COMPUTE_FUNCTIONAL_TASKS
# command: rake test:functional_parallel
# run all functional test files concurrently
desc "Autotask - run functional tests in parallel"
multitask :functional_parallel => COMPUTE_FUNCTIONAL_TASKS
# command pattern: rake test:integration_test_file.rb
# autogenerates a rake task for every test file added to test/integration
COMPUTE_INTEGRATION_TASKS = []
Dir.glob("test/integration/*_test.rb").each do |task|
collection = task.gsub(/test\/integration\//, "")
Rake::TestTask.new(:"#{collection}") do |t|
t.libs << "test"
t.description = "Autotask - run integration tests - #{collection}"
t.pattern = FileList["test/integration/#{collection}"]
t.warning = false
t.verbose = true
end
COMPUTE_INTEGRATION_TASKS << "#{collection}"
end
# command: rake test:integration
# run all integration test files
desc "Autotask - run integration tests"
task :integration => COMPUTE_INTEGRATION_TASKS
# command: rake test:integration_parallel
# run all integration test files concurrently
desc "Autotask - run integration tests in parallel"
multitask :integration_parallel => COMPUTE_INTEGRATION_TASKS
end