Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip benchmark tests #152

Merged
merged 4 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/expected_results.json
Original file line number Diff line number Diff line change
@@ -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"}]}
5 changes: 5 additions & 0 deletions tests/benchmarks/two_fer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class TwoFer
def self.two_fer(name = "you")
"One for #{name}, one for me."
end
end
11 changes: 11 additions & 0 deletions tests/benchmarks/two_fer_benchmark_test.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions tests/benchmarks/two_fer_test.rb
Original file line number Diff line number Diff line change
@@ -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