模块 Minitest::Guard
提供了一组简单的保护措施,您可以在测试中使用这些措施,如果测试不适用,则跳过执行。这些方法作为实例方法和类方法混合到 Test
中,因此您可以在测试方法内部或外部使用它们。
def test_something_for_mri skip "bug 1234" if jruby? # ... end if windows? then # ... lots of test methods ... end
公共实例方法
jruby?(platform = RUBY_PLATFORM) 点击以切换源代码
是否在 jruby 上运行?
# File minitest-5.25.4/lib/minitest.rb, line 1124 def jruby? platform = RUBY_PLATFORM "java" == platform end
maglev?(platform = defined?(RUBY_ENGINE) && RUBY_ENGINE) 点击以切换源代码
是否在 maglev 上运行?
# File minitest-5.25.4/lib/minitest.rb, line 1131 def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE where = Minitest.filter_backtrace(caller).first where = where.split(":in ", 2).first # clean up noise warn "DEPRECATED: `maglev?` called from #{where}. This will fail in Minitest 6." "maglev" == platform end
mri?(platform = RUBY_DESCRIPTION) 点击以切换源代码
是否在 mri 上运行?
# File minitest-5.25.4/lib/minitest.rb, line 1141 def mri? platform = RUBY_DESCRIPTION platform.start_with? "ruby" end
osx?(platform = RUBY_PLATFORM) 点击以切换源代码
是否在 macOS 上运行?
# File minitest-5.25.4/lib/minitest.rb, line 1148 def osx? platform = RUBY_PLATFORM platform.include? "darwin" end
rubinius?(platform = defined?(RUBY_ENGINE) && RUBY_ENGINE) 点击以切换源代码
是否在 rubinius 上运行?
# File minitest-5.25.4/lib/minitest.rb, line 1155 def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE where = Minitest.filter_backtrace(caller).first where = where.split(":in ", 2).first # clean up noise warn "DEPRECATED: `rubinius?` called from #{where}. This will fail in Minitest 6." "rbx" == platform end
windows?(platform = RUBY_PLATFORM) 点击以切换源代码
是否在 windows 上运行?
# File minitest-5.25.4/lib/minitest.rb, line 1165 def windows? platform = RUBY_PLATFORM /mswin|mingw/.match? platform end