Module: Minitest

Defined in:
lib/minitest/proptest.rb,
lib/minitest/proptest/gen.rb,
lib/minitest/proptest/status.rb,
lib/minitest/proptest_plugin.rb,
lib/minitest/proptest/version.rb,
lib/minitest/proptest/property.rb,
lib/minitest/proptest/gen/value_generator.rb

Defined Under Namespace

Modules: Assertions, Proptest Classes: ResultsDatabase

Class Method Summary collapse

Class Method Details

.plugin_proptest_init(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/minitest/proptest_plugin.rb', line 12

def self.plugin_proptest_init(options)
  %i[Int8 Int16 Int32 Int64
     UInt8 UInt16 UInt32 UInt64
     Float32 Float64
     ASCIIChar Char
     Bool
    ].each do |const|
    unless Minitest::Assertions.const_defined?(const)
      ::Minitest::Assertions.const_set(const, ::Minitest::Proptest::Gen.const_get(const))
    end
  end

  self.reporter << Proptest.reporter

  Proptest.set_seed(options[:seed]) if options.key?(:seed)
end

.plugin_proptest_options(opts, _options) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/minitest/proptest_plugin.rb', line 29

def self.plugin_proptest_options(opts, _options)
  opts.on('--max-success', Integer, "Maximum number of successful cases to verify for each property (Default: #{Minitest::Proptest::DEFAULT_MAX_SUCCESS})") do |max_success|
    Proptest.max_success = max_success
  end
  opts.on('--max-discard-ratio', Integer, "Maximum ratio of successful cases versus discarded cases per property (Default: #{Minitest::Proptest::DEFAULT_MAX_DISCARD_RATIO}:1)") do |max_success|
    Proptest.max_success = max_success
  end
  opts.on('--max-size', Integer, "Maximum amount of entropy a single case may use in bytes (Default: #{Minitest::Proptest::DEFAULT_MAX_SIZE} bytes)") do |max_size|
    Proptest.max_size = max_size
  end
  opts.on('--max-shrinks', Integer, "Maximum number of shrink iterations a single failure reduction may use (Default: #{Minitest::Proptest::DEFAULT_MAX_SHRINKS})") do |max_shrinks|
    Proptest.max_shrinks = max_shrinks
  end
  opts.on('--results-db', String, "Location of the file to persist most recent failure cases.  Implies --use-db.  (Default: #{Minitest::Proptest::DEFAULT_DB_LOCATION})") do |db_path|
    Proptest.result_db = db_path
    Proptest.use_db!
  end
  opts.on('--use-db', 'Persist previous failures in a database and use them before generating new values.  Helps prevent flaky builds.  (Default: false)') do
    Proptest.use_db!
  end
end