diff --git a/lib/test_runner.rb b/lib/test_runner.rb index 4d6441e..953329f 100644 --- a/lib/test_runner.rb +++ b/lib/test_runner.rb @@ -39,6 +39,8 @@ def run Minitest::PrideIO.pride! Dir.glob(File.join(input_path, "*_test.rb")).sort.each do |test_file| + next if test_file.end_with?("_benchmark_test.rb") + reporter.set_metadata(test_file, ExtractMetadata.(test_file)) begin diff --git a/tests/benchmarks/expected_results.json b/tests/benchmarks/expected_results.json new file mode 100644 index 0000000..60e6acd --- /dev/null +++ b/tests/benchmarks/expected_results.json @@ -0,0 +1 @@ +{"version":2,"status":"pass","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"pass"},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass"},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass"}]} diff --git a/tests/benchmarks/two_fer.rb b/tests/benchmarks/two_fer.rb new file mode 100644 index 0000000..72ac309 --- /dev/null +++ b/tests/benchmarks/two_fer.rb @@ -0,0 +1,5 @@ +class TwoFer + def self.two_fer(name = "you") + "One for #{name}, one for me." + end +end diff --git a/tests/benchmarks/two_fer_benchmark_test.rb b/tests/benchmarks/two_fer_benchmark_test.rb new file mode 100644 index 0000000..1900f81 --- /dev/null +++ b/tests/benchmarks/two_fer_benchmark_test.rb @@ -0,0 +1,11 @@ +require 'minitest/autorun' +require 'minitest/benchmark' +require_relative 'two_fer' + +class TwoFerBenchmarkTest < Minitest::Benchmark + def bench_two_fer + assert_performance_linear 0.9999 do |n| # n is a range value + TwoFer.two_fer + end + end +end \ No newline at end of file diff --git a/tests/benchmarks/two_fer_test.rb b/tests/benchmarks/two_fer_test.rb new file mode 100644 index 0000000..1d91d07 --- /dev/null +++ b/tests/benchmarks/two_fer_test.rb @@ -0,0 +1,20 @@ +require 'minitest/autorun' +require_relative 'two_fer' + +# Common test data version: 1.2.0 4fc1acb +class TwoFerTest < Minitest::Test + def test_no_name_given + # skip + assert_equal "One for you, one for me.", TwoFer.two_fer + end + + def test_a_name_given + skip + assert_equal "One for Alice, one for me.", TwoFer.two_fer("Alice") + end + + def test_another_name_given + skip + assert_equal "One for Bob, one for me.", TwoFer.two_fer("Bob") + end +end