minitest-suite 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +20 -0
- data/README.md +99 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/Gemfile +5 -0
- data/example/Gemfile.lock +22 -0
- data/example/Rakefile +9 -0
- data/example/test/sweet_test.rb +74 -0
- data/lib/minitest/suite.rb +60 -0
- data/lib/minitest/suite/version.rb +5 -0
- data/minitest-suite.gemspec +27 -0
- data/script/test +7 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14315494c6d4e85d5f6a754070add34121f58dac9499820f1a3936496c71a38e
|
4
|
+
data.tar.gz: 7c5e5da23030fb27f8f4b3a2db983f918ca62a8aae89527bb28b0c78cceafb77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4ce626b86e3c40b8091078c9210f18a714d7c67cc1cdcbcbea77f240ca7dfa4014c3280d286cfaaf84cbb44679fa9c7527e4ebe2692a216fc9cbdaf81d468c6
|
7
|
+
data.tar.gz: db057fcf019dbf786c7755b300df0c226cd6cf27c54c5572765ccdd3c0e6731558097efd34ed962a0c30fa248bce45064c6ae4d086dc99625274f08c612978a2
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0.1
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.15
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
minitest-suite (0.0.1)
|
5
|
+
minitest
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
minitest (5.14.4)
|
12
|
+
parallel (1.20.1)
|
13
|
+
parser (3.0.2.0)
|
14
|
+
ast (~> 2.4.1)
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (13.0.6)
|
17
|
+
regexp_parser (2.1.1)
|
18
|
+
rexml (3.2.5)
|
19
|
+
rubocop (1.18.4)
|
20
|
+
parallel (~> 1.10)
|
21
|
+
parser (>= 3.0.0.0)
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
23
|
+
regexp_parser (>= 1.8, < 3.0)
|
24
|
+
rexml
|
25
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
26
|
+
ruby-progressbar (~> 1.7)
|
27
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
28
|
+
rubocop-ast (1.8.0)
|
29
|
+
parser (>= 3.0.1.1)
|
30
|
+
rubocop-performance (1.11.4)
|
31
|
+
rubocop (>= 1.7.0, < 2.0)
|
32
|
+
rubocop-ast (>= 0.4.0)
|
33
|
+
ruby-progressbar (1.11.0)
|
34
|
+
standard (1.1.7)
|
35
|
+
rubocop (= 1.18.4)
|
36
|
+
rubocop-performance (= 1.11.4)
|
37
|
+
unicode-display_width (2.0.0)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
arm64-darwin-20
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
minitest-suite!
|
44
|
+
rake
|
45
|
+
standard
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.2.15
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2021 Test Double, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# minitest-suite
|
2
|
+
|
3
|
+
The minitest-suite gem modifies the way
|
4
|
+
[Minitest](https://github.com/seattlerb/minitest) shuffles the order in which
|
5
|
+
`Minitest::Test` subclasses are run by allowing you to organize them into
|
6
|
+
sub-suites or groups.
|
7
|
+
|
8
|
+
This can be handy when you want to (usually for performance reasons) want to run
|
9
|
+
one logical grouping of tests at a time before moving onto the next.
|
10
|
+
|
11
|
+
## Using minitest-suite
|
12
|
+
|
13
|
+
### Install and setup
|
14
|
+
|
15
|
+
Add the gem to your `Gemfile`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem "minitest-suite"
|
19
|
+
```
|
20
|
+
|
21
|
+
And then require the gem near the top of your test helper:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require "minitest/suite"
|
25
|
+
```
|
26
|
+
|
27
|
+
### Declaring suites
|
28
|
+
|
29
|
+
To associate a test class, just pass a suite name to `suite` in the body of each
|
30
|
+
test class:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class SweetTest < Minitest::Test
|
34
|
+
suite :sugary
|
35
|
+
|
36
|
+
def test_blood_sugar
|
37
|
+
#
|
38
|
+
end
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Normally, Minitest will shuffle the order of all your test classes. But if
|
43
|
+
`minitest-suite` is loaded, your tests will be grouped by any suites you've
|
44
|
+
defined: your suites will be shuffled first, then the test classes within each
|
45
|
+
of those suites will be shuffled.
|
46
|
+
|
47
|
+
For example, suppose you have 4 test classes, two fruits and two vegetables:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class Pumpkin < Minitest::Test
|
51
|
+
suite :veggie
|
52
|
+
def test_it() = puts("🎃")
|
53
|
+
end
|
54
|
+
|
55
|
+
class Pear < Minitest::Test
|
56
|
+
suite :fruit
|
57
|
+
def test_it() = puts("🍐")
|
58
|
+
end
|
59
|
+
|
60
|
+
class Pepper < Minitest::Test
|
61
|
+
suite :veggie
|
62
|
+
def test_it() = puts("🌶")
|
63
|
+
end
|
64
|
+
|
65
|
+
class Apple < Minitest::Test
|
66
|
+
suite :fruit
|
67
|
+
def test_it() = puts("🍎")
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
By declaring their `suite` above, you're guaranteed the two fruits will run next
|
72
|
+
to each other and the two vegetables will run next to each other (even though
|
73
|
+
the order will still be randomized):
|
74
|
+
|
75
|
+
```
|
76
|
+
# Running:
|
77
|
+
|
78
|
+
🍐
|
79
|
+
.🍎
|
80
|
+
.🎃
|
81
|
+
.🌶
|
82
|
+
.
|
83
|
+
```
|
84
|
+
|
85
|
+
To wit, the above strategy will ensure you'd never see this test order:
|
86
|
+
🍐,🌶,🍎,🎃.
|
87
|
+
|
88
|
+
Looking for more? Check out this repo's [example
|
89
|
+
test](/example/test/sweet_test.rb).
|
90
|
+
|
91
|
+
## Code of Conduct
|
92
|
+
|
93
|
+
This project follows Test Double's [code of
|
94
|
+
conduct](https://testdouble.com/code-of-conduct) for all community interactions,
|
95
|
+
including (but not limited to) one-on-one communications, public posts/comments,
|
96
|
+
code reviews, pull requests, and GitHub issues. If violations occur, Test Double
|
97
|
+
will take any action they deem appropriate for the infraction, up to and
|
98
|
+
including blocking a user from the organization's repositories.
|
99
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
require "bundler/setup"
|
4
|
+
require "minitest/suite"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/example/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
minitest-suite (0.0.1)
|
5
|
+
minitest
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
minitest (5.14.4)
|
11
|
+
rake (13.0.6)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
arm64-darwin-20
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
minitest
|
18
|
+
minitest-suite!
|
19
|
+
rake
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
2.2.15
|
data/example/Rakefile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
CLASS_COUNT = 10
|
2
|
+
TEST_COUNT = 10
|
3
|
+
|
4
|
+
executions = []
|
5
|
+
at_exit do
|
6
|
+
# Everything runs
|
7
|
+
if CLASS_COUNT * TEST_COUNT != executions.size
|
8
|
+
raise "Expected #{CLASS_COUNT * TEST_COUNT} tests to run but was #{executions.size}"
|
9
|
+
end
|
10
|
+
|
11
|
+
suite_order = executions.each_with_object([]) { |exe, memo|
|
12
|
+
memo << exe[:suite] unless memo.last == exe[:suite]
|
13
|
+
}
|
14
|
+
if suite_order.uniq.sort != suite_order.sort
|
15
|
+
raise "Expected each suite to be run contiguously, but was not. Actual suite execution order was: #{suite_order}"
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "Run order:"
|
19
|
+
executions.each.with_index do |execution, i|
|
20
|
+
puts "#{i + 1}. #{execution[:suite]}: #{execution[:class]}##{execution[:method]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "minitest/suite"
|
25
|
+
require "minitest/autorun"
|
26
|
+
|
27
|
+
CLASS_COUNT.times do |i|
|
28
|
+
class_name = "TestCase#{i}"
|
29
|
+
Object.const_set(class_name, Class.new(Minitest::Test) {
|
30
|
+
if i <= 2
|
31
|
+
suite_name = :zeroonetwo
|
32
|
+
suite :zeroonetwo
|
33
|
+
elsif i <= 5
|
34
|
+
suite_name = :threefourfive
|
35
|
+
suite :threefourfive
|
36
|
+
elsif i <= 7
|
37
|
+
suite_name = :sixseven
|
38
|
+
Minitest::Suite.register(suite_name: :sixseveneight, test_class: self)
|
39
|
+
else
|
40
|
+
suite_name = :unsuitened
|
41
|
+
end
|
42
|
+
|
43
|
+
TEST_COUNT.times do |j|
|
44
|
+
method_name = "test_#{j}"
|
45
|
+
define_method "test_#{j}" do
|
46
|
+
executions << {
|
47
|
+
class: class_name,
|
48
|
+
method: method_name,
|
49
|
+
suite: suite_name
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
})
|
54
|
+
end
|
55
|
+
|
56
|
+
class Pumpkin < Minitest::Test
|
57
|
+
suite :veggie
|
58
|
+
def test_it() = puts("🎃")
|
59
|
+
end
|
60
|
+
|
61
|
+
class Pear < Minitest::Test
|
62
|
+
suite :fruit
|
63
|
+
def test_it() = puts("🍐")
|
64
|
+
end
|
65
|
+
|
66
|
+
class Pepper < Minitest::Test
|
67
|
+
suite :veggie
|
68
|
+
def test_it() = puts("🌶")
|
69
|
+
end
|
70
|
+
|
71
|
+
class Apple < Minitest::Test
|
72
|
+
suite :fruit
|
73
|
+
def test_it() = puts("🍎")
|
74
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative "suite/version"
|
2
|
+
require "minitest"
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
module Suite
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
def self.register(suite_name:, test_class:)
|
9
|
+
raise Error.new("suite_name must be a Symbol") unless suite_name.is_a?(Symbol)
|
10
|
+
raise Error.new("test_class must be a Minitest::Test") unless test_class.ancestors.include?(Minitest::Test)
|
11
|
+
if (conflicting_suite_name = (suites.keys - [suite_name]).find { |suite_name| suites[suite_name].include?(test_class) })
|
12
|
+
raise Error.new("#{test_class.name || "Class"} is already registered to the #{conflicting_suite_name.inspect} suite")
|
13
|
+
end
|
14
|
+
suites[suite_name] = (suites[suite_name] + [test_class]).uniq
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.suites
|
18
|
+
Thread.current[:minitest_suites] || reset
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.reset
|
22
|
+
Thread.current[:minitest_suites] = Hash.new { [] }
|
23
|
+
end
|
24
|
+
|
25
|
+
class PartialArrayProxy < Array
|
26
|
+
def shuffle
|
27
|
+
suites = (Suite.suites.keys + [:unsuitened]).shuffle
|
28
|
+
suites.flat_map { |suite|
|
29
|
+
if suite == :unsuitened
|
30
|
+
(self - Suite.suites.values.flatten).shuffle
|
31
|
+
else
|
32
|
+
Suite.suites[suite].shuffle
|
33
|
+
end
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def reject
|
38
|
+
self.class.new(super)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module Minitest
|
45
|
+
class Test < Runnable
|
46
|
+
def self.suite(suite_name)
|
47
|
+
Minitest::Suite.register(suite_name: suite_name, test_class: self)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Runnable
|
52
|
+
class << self
|
53
|
+
undef_method :runnables
|
54
|
+
define_method :runnables do
|
55
|
+
return @@runnables if @@runnables.is_a?(Minitest::Suite::PartialArrayProxy)
|
56
|
+
@@runnables = Minitest::Suite::PartialArrayProxy.new(@@runnables)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "lib/minitest/suite/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "minitest-suite"
|
5
|
+
spec.version = Minitest::Suite::VERSION
|
6
|
+
spec.authors = ["Justin Searls"]
|
7
|
+
spec.email = ["searls@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "Re-order your Minitest suite into logical sub-suites/groups"
|
10
|
+
spec.homepage = "https://github.com/testdouble/minitest-suite"
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "minitest"
|
27
|
+
end
|
data/script/test
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-suite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Searls
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- searls@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".github/workflows/main.yml"
|
35
|
+
- ".gitignore"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- example/Gemfile
|
45
|
+
- example/Gemfile.lock
|
46
|
+
- example/Rakefile
|
47
|
+
- example/test/sweet_test.rb
|
48
|
+
- lib/minitest/suite.rb
|
49
|
+
- lib/minitest/suite/version.rb
|
50
|
+
- minitest-suite.gemspec
|
51
|
+
- script/test
|
52
|
+
homepage: https://github.com/testdouble/minitest-suite
|
53
|
+
licenses: []
|
54
|
+
metadata:
|
55
|
+
homepage_uri: https://github.com/testdouble/minitest-suite
|
56
|
+
source_code_uri: https://github.com/testdouble/minitest-suite
|
57
|
+
changelog_uri: https://github.com/testdouble/minitest-suite/blob/main/CHANGELOG.md
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.4.0
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubygems_version: 3.2.15
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Re-order your Minitest suite into logical sub-suites/groups
|
77
|
+
test_files: []
|