How to use process_env method of Minitest Package

Best Minitest_ruby code snippet using Minitest.process_env

test_task.rb

Source:test_task.rb Github

copy

Full Screen

...34 # optional block to customize variables.35 def self.create name = :test, &block36 task = new name37 task.instance_eval(&block) if block38 task.process_env39 task.define40 task41 end42 ##43 # Extra arguments to pass to the tests. Defaults empty but gets44 # populated by a number of enviroment variables:45 #46 # N (-n flag) :: a string or regexp of tests to run.47 # X (-e flag) :: a string or regexp of tests to exclude.48 # A (arg) :: quick way to inject an arbitrary argument (eg A=--help).49 #50 # See #process_env51 attr_accessor :extra_args52 ##53 # The code to load the framework. Defaults to requiring54 # minitest/autorun...55 #56 # Why do I have this as an option?57 attr_accessor :framework58 ##59 # Extra library directories to include. Defaults to %w[lib test60 # .]. Also uses $MT_LIB_EXTRAS allowing you to dynamically61 # override/inject directories for custom runs.62 attr_accessor :libs63 ##64 # The name of the task and base name for the other tasks generated.65 attr_accessor :name66 ##67 # File globs to find test files. Defaults to something sensible to68 # find test files under the test directory.69 attr_accessor :test_globs70 ##71 # Turn on ruby warnings (-w flag). Defaults to true.72 attr_accessor :warning73 ##74 # Optional: Additional ruby to run before the test framework is loaded.75 attr_accessor :test_prelude76 ##77 # Print out commands as they run. Defaults to Rake's +trace+ (-t78 # flag) option.79 attr_accessor :verbose80 ##81 # Use TestTask.create instead.82 def initialize name = :test # :nodoc:83 self.extra_args = []84 self.framework = %(require "minitest/autorun")85 self.libs = %w[lib test .]86 self.name = name87 self.test_globs = ["test/**/test_*.rb",88 "test/**/*_test.rb"]89 self.test_prelude = nil90 self.verbose = Rake.application.options.trace91 self.warning = true92 end93 ##94 # Extract variables from the environment and convert them to95 # command line arguments. See #extra_args.96 #97 # Environment Variables:98 #99 # MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.100 # N :: Tests to run (string or /regexp/).101 # X :: Tests to exclude (string or /regexp/).102 # A :: Any extra arguments. Honors shell quoting.103 #104 # Deprecated:105 #106 # TESTOPTS :: For argument passing, use +A+.107 # N :: For parallel testing, use +MT_CPU+.108 # FILTER :: Same as +TESTOPTS+.109 def process_env110 warn "TESTOPTS is deprecated in Minitest::TestTask. Use A instead" if111 ENV["TESTOPTS"]112 warn "FILTER is deprecated in Minitest::TestTask. Use A instead" if113 ENV["FILTER"]114 warn "N is deprecated in Minitest::TestTask. Use MT_CPU instead" if115 ENV["N"] && ENV["N"].to_i > 0116 lib_extras = (ENV["MT_LIB_EXTRAS"] || "").split File::PATH_SEPARATOR117 self.libs[0,0] = lib_extras118 extra_args << "-n" << ENV["N"] if ENV["N"]119 extra_args << "-e" << ENV["X"] if ENV["X"]120 extra_args.concat Shellwords.split(ENV["TESTOPTS"]) if ENV["TESTOPTS"]121 extra_args.concat Shellwords.split(ENV["FILTER"]) if ENV["FILTER"]122 extra_args.concat Shellwords.split(ENV["A"]) if ENV["A"]123 ENV.delete "N" if ENV["N"]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Minitest_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful