Skip to content

Commit

Permalink
[DSL] Changed the test framework to Minitest and configured the reporter
Browse files Browse the repository at this point in the history
Previously, the "test-unit" gem has been use as the test framework,
which caused the output to lack the test names, and only show the
"dot" report.

This patch switches the platform, changes the superclass for all the
tests to inherit from `Minitest::Test`, and adds assertions to be
compatible with `Test::Unit`.
  • Loading branch information
karmi committed Apr 8, 2017
1 parent bb680d5 commit 1af09b5
Show file tree
Hide file tree
Showing 122 changed files with 171 additions and 153 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace :generate do
module Elasticsearch
module Test
module #{module_name}
class #{class_name}Test < ::Test::Unit::TestCase
class #{class_name}Test < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::#{module_name}
context "#{class_name} #{options[:type]}" do
Expand Down
5 changes: 2 additions & 3 deletions elasticsearch-dsl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ Gem::Specification.new do |s|

s.add_development_dependency 'shoulda-context'
s.add_development_dependency 'mocha'
s.add_development_dependency 'minitest', '~> 4.0'
s.add_development_dependency 'minitest-reporters'
s.add_development_dependency 'minitest', '~> 5'
s.add_development_dependency 'minitest-reporters', '~> 1'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'simplecov-rcov'
s.add_development_dependency 'ci_reporter', '~> 1.9'
s.add_development_dependency 'yard'
s.add_development_dependency 'cane'
Expand Down
23 changes: 21 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

at_exit { Elasticsearch::Test::IntegrationTestCase.__run_at_exit_hooks }

require 'test/unit'
require 'minitest/autorun'
require 'shoulda-context'
require 'mocha/setup'

require 'minitest/reporters'
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
# Minitest::Reporters.use! [ Minitest::Reporters::SpecReporter.new,
# Minitest::Reporters::JUnitReporter.new,
# Minitest::Reporters::HtmlReporter.new ]

require 'elasticsearch'
require 'elasticsearch/extensions/test/cluster'
Expand All @@ -22,7 +25,23 @@

module Elasticsearch
module Test
class IntegrationTestCase < ::Test::Unit::TestCase
module Assertions
def assert_nothing_raised(*)
yield
end
end

class UnitTestCase < ::Minitest::Test
include Assertions
alias_method :assert_not_nil, :refute_nil
alias_method :assert_raise, :assert_raises
end

class IntegrationTestCase < ::Minitest::Test
include Assertions
alias_method :assert_not_nil, :refute_nil
alias_method :assert_raise, :assert_raises

include Elasticsearch::Extensions::Test
extend StartupShutdown

Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/avg_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class AvgTest < ::Test::Unit::TestCase
class AvgTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Avg agg" do
Expand Down
10 changes: 5 additions & 5 deletions test/unit/aggregations/cardinality_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class CardinalityTest < ::Test::Unit::TestCase
class CardinalityTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Cardinality agg" do
Expand All @@ -12,21 +12,21 @@ class CardinalityTest < ::Test::Unit::TestCase
should "be converted to a Hash" do
assert_equal({ cardinality: {} }, subject.to_hash)
end

should "have option methods" do
subject = Cardinality.new :foo

subject.field 'bar'
subject.precision_threshold 'bar'
subject.rehash 'bar'
subject.script 'bar'
subject.params 'bar'

assert_equal %w[ field params precision_threshold rehash script ],
subject.to_hash[:cardinality][:foo].keys.map(&:to_s).sort
assert_equal 'bar', subject.to_hash[:cardinality][:foo][:field]
end

should "take a block" do
subject = Cardinality.new :foo do
field 'bar'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/children_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class ChildrenTest < ::Test::Unit::TestCase
class ChildrenTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Children aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/date_histogram_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class DateHistogramTest < ::Test::Unit::TestCase
class DateHistogramTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "DateHistogram aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/date_range_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class DateRangeTest < ::Test::Unit::TestCase
class DateRangeTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "DateRange aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/extended_stats_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class ExtendedStatsTest < ::Test::Unit::TestCase
class ExtendedStatsTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "ExtendedStats agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class FilterTest < ::Test::Unit::TestCase
class FilterTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Filter agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/filters_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class FiltersTest < ::Test::Unit::TestCase
class FiltersTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Filters agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/geo_bounds_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class GeoBoundsTest < ::Test::Unit::TestCase
class GeoBoundsTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "GeoBounds agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/geo_distance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class GeoDistanceTest < ::Test::Unit::TestCase
class GeoDistanceTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "GeoDistance aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/geohash_grid_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class GeohashGridTest < ::Test::Unit::TestCase
class GeohashGridTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "GeohashGrid aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/global_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class GlobalTest < ::Test::Unit::TestCase
class GlobalTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Global agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/histogram_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class HistogramTest < ::Test::Unit::TestCase
class HistogramTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Histogram aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/ip_range_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class IpRangeTest < ::Test::Unit::TestCase
class IpRangeTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "IpRange aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/max_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class MaxTest < ::Test::Unit::TestCase
class MaxTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Max agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/min_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class MinTest < ::Test::Unit::TestCase
class MinTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Min agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/missing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class MissingTest < ::Test::Unit::TestCase
class MissingTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Missing aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/nested_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class NestedTest < ::Test::Unit::TestCase
class NestedTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Nested aggregation" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/percentile_ranks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class PercentileRanksTest < ::Test::Unit::TestCase
class PercentileRanksTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "PercentileRanks agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/percentiles_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class PercentilesTest < ::Test::Unit::TestCase
class PercentilesTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Percentiles agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/avg_bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class AvgBucketTest < ::Test::Unit::TestCase
class AvgBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Avg Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/bucket_script_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class BucketScriptTest < ::Test::Unit::TestCase
class BucketScriptTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Bucket Script agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/bucket_selector_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class BucketSelectorTest < ::Test::Unit::TestCase
class BucketSelectorTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Bucket Selector agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/cumulative_sum_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class CumulativeSumTest < ::Test::Unit::TestCase
class CumulativeSumTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Cumulative Sum Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/derivative_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class DerivativeTest < ::Test::Unit::TestCase
class DerivativeTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Derivative agg" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class ExtendedStatsBucketTest < ::Test::Unit::TestCase
class ExtendedStatsBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Extended Stats Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/max_bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class MaxBucketTest < ::Test::Unit::TestCase
class MaxBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Max Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/min_bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class MinBucketTest < ::Test::Unit::TestCase
class MinBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Min Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/moving_avg_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class MovingAvgTest < ::Test::Unit::TestCase
class MovingAvgTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Moving Average Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/percentiles_bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class PercentilesBucketTest < ::Test::Unit::TestCase
class PercentilesBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Percentiles Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/serial_diff_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class SerialDiffTest < ::Test::Unit::TestCase
class SerialDiffTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Serial Defferencing agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/stats_bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class StatsBucketTest < ::Test::Unit::TestCase
class StatsBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Stats Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/pipeline/sum_bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class SumBucketTest < ::Test::Unit::TestCase
class SumBucketTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Sum Bucket agg" do
Expand Down
2 changes: 1 addition & 1 deletion test/unit/aggregations/range_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Elasticsearch
module Test
module Aggregations
class RangeTest < ::Test::Unit::TestCase
class RangeTest < ::Elasticsearch::Test::UnitTestCase
include Elasticsearch::DSL::Search::Aggregations

context "Range aggregation" do
Expand Down
Loading

0 comments on commit 1af09b5

Please sign in to comment.