      flags = []
      @opt.def_option("-[a-z]") {|x| flags << x}
 diff --git a/test/optparse/test_getopts.rb b/test/optparse/test_getopts.rb
-index 3711e6f269..190b8ccb36 100644
+index 3711e6f269..41627597cf 100644
 --- a/test/optparse/test_getopts.rb
 +++ b/test/optparse/test_getopts.rb
-@@ -1,10 +1,8 @@
--# frozen_string_literal: false
-+# frozen_string_literal: true
- require 'test/unit'
- require 'optparse'
+@@ -1,9 +1,6 @@
+-# frozen_string_literal: false
+-require 'test/unit'
+-require 'optparse'
++# frozen_string_literal: true
++require_relative 'optparse_setup'
  
 -class TestOptionParser < Test::Unit::TestCase
 -end
--class TestOptionParser::Getopts < Test::Unit::TestCase
-+class TestOptionParserGetopts < Test::Unit::TestCase
+ class TestOptionParser::Getopts < Test::Unit::TestCase
    def setup
      @opt = OptionParser.new
-   end
 diff --git a/test/optparse/test_kwargs.rb b/test/optparse/test_kwargs.rb
 index 78d7e2ee9c..555caa991a 100644
 --- a/test/optparse/test_kwargs.rb

diff --git a/test/optparse/test_acceptable.rb b/test/optparse/test_acceptable.rb
index 5c3fbdb10c..802482302d 100644
--- a/test/optparse/test_acceptable.rb

     r = nil
     o = OptionParser.new do |opts|
diff --git a/test/optparse/test_zsh_completion.rb b/test/optparse/test_zsh_completion.rb
index 1bc6c7f0bb..8f098d22ed 100644
--- a/test/optparse/test_zsh_completion.rb
+++ b/test/optparse/test_zsh_completion.rb
@@ -1,10 +1,7 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'optparse'
+# frozen_string_literal: true
+require_relative 'optparse_setup'
 
-class TestOptionParser < Test::Unit::TestCase
-end
-class TestOptionParser::BashCompletion < Test::Unit::TestCase
+class TestOptionParser::BashCompletionZSH < Test::Unit::TestCase
   def setup
     @opt = OptionParser.new
     @opt.define("-z", "zzz") {}
@@ -14,7 +11,7 @@ def setup
   end
 
   def test_compsys
