Refactoring the creation of TestTasks to remove code duplication.
Merge pull request #10423 from wangjohn/refactoring_testing_rakefile

Refactoring the creation of TestTasks to remove code duplication.