Class: MiniTest::Spec
- Inherits:
-
Unit::TestCase
- Object
- Unit::TestCase
- MiniTest::Spec
- Extended by:
- DSL
- Defined in:
- lib/minitest/spec.rb,
lib/minitest/benchmark.rb
Overview
MiniTest::Spec – The faster, better, less-magical spec framework!
For a list of expectations, see MiniTest::Expectations.
Defined Under Namespace
Modules: DSL
Constant Summary collapse
Constants inherited from Unit::TestCase
Unit::TestCase::PASSTHROUGH_EXCEPTIONS
Constants included from Assertions
Instance Attribute Summary
Attributes included from DSL
Attributes inherited from Unit::TestCase
Class Method Summary collapse
-
.bench(name, &block) ⇒ Object
This is used to define a new benchmark method.
-
.bench_performance_constant(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is constant.
-
.bench_performance_exponential(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is exponential.
-
.bench_performance_linear(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is linear.
-
.bench_range(&block) ⇒ Object
Specifies the ranges used for benchmarking for that class.
Methods included from DSL
after, before, children, create, describe_stack, it, let, name, nuke_test_methods!, register_spec_type, spec_type, subject, to_s
Methods inherited from Unit::TestCase
#assert_performance, #assert_performance_constant, #assert_performance_exponential, #assert_performance_linear, #assert_performance_logarithmic, #assert_performance_power, bench_exp, bench_linear, benchmark_methods, benchmark_suites, current, #fit_error, #fit_exponential, #fit_linear, #fit_logarithmic, #fit_power, i_suck_and_my_tests_are_order_dependent!, inherited, #initialize, #io, #io?, make_my_diffs_pretty!, parallelize_me!, #passed?, reset, #run, #setup, #sigma, #teardown, test_methods, test_order, test_suites, #validation_for_fit
Methods included from Unit::Guard
#jruby?, maglev?, #mri?, #rubinius?, #windows?
Methods included from Assertions
#_assertions, #_assertions=, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_operator, #assert_output, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skipped?, #synchronize
Methods included from Unit::LifecycleHooks
#after_setup, #after_teardown, #before_setup, #before_teardown
Constructor Details
This class inherits a constructor from MiniTest::Unit::TestCase
Class Method Details
.bench(name, &block) ⇒ Object
This is used to define a new benchmark method. You usually don’t use this directly and is intended for those needing to write new performance curve fits (eg: you need a specific polynomial fit).
See ::bench_performance_linear for an example of how to use this.
359 360 361 |
# File 'lib/minitest/benchmark.rb', line 359 def self.bench name, &block define_method "bench_#{name.gsub(/\W+/, '_')}", &block end |
.bench_performance_constant(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is constant.
describe "my class" do
bench_performance_constant "zoom_algorithm!" do |n|
@obj.zoom_algorithm!(n)
end
end
403 404 405 406 407 |
# File 'lib/minitest/benchmark.rb', line 403 def self.bench_performance_constant name, threshold = 0.99, &work bench name do assert_performance_constant threshold, &work end end |
.bench_performance_exponential(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is exponential.
describe "my class" do
bench_performance_exponential "algorithm" do |n|
@obj.algorithm(n)
end
end
418 419 420 421 422 |
# File 'lib/minitest/benchmark.rb', line 418 def self.bench_performance_exponential name, threshold = 0.99, &work bench name do assert_performance_exponential threshold, &work end end |
.bench_performance_linear(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is linear.
describe "my class" do
bench_performance_linear "fast_algorithm", 0.9999 do |n|
@obj.fast_algorithm(n)
end
end
388 389 390 391 392 |
# File 'lib/minitest/benchmark.rb', line 388 def self.bench_performance_linear name, threshold = 0.99, &work bench name do assert_performance_linear threshold, &work end end |
.bench_range(&block) ⇒ Object
Specifies the ranges used for benchmarking for that class.
bench_range do
bench_exp(2, 16, 2)
end
See Unit::TestCase.bench_range for more details.
372 373 374 375 376 377 |
# File 'lib/minitest/benchmark.rb', line 372 def self.bench_range &block return super unless block = (class << self; self; end) .send :define_method, "bench_range", &block end |