Ruby Minitest 0测试

时间:2017-09-28 22:17:20

标签: ruby minitest

嗨,我对Ruby完全不熟悉。我正在尝试运行Minitests,它可以正常工作,直到我将一个构造函数添加到我的CountDown类。

以下是代码:

require 'benchmark'

require 'minitest/autorun'

#! /usr/bin/env ruby
#This is our countdown class
# :reek:DuplicateMethodCall
# :reek:TooManyStatements
class CountDown

  def initialize(time)
    @time = time
  end

  def count()
    wait_time = @time.to_i
    print wait_time.to_s + " seconds left\n"
    sleep 1
    wait_time = wait_time - 1
    wait_time.downto(1).each do |time_left|
        sleep 1
        print time_left.to_s + " seconds left\n" if (time_left % 60) == 0
    end
    print "\a"
  end
end
#This class is responsible for our test cases
class CountDownTest < Minitest::Test

  def setup
    @count_down = CountDown.new(10)
  end

  def testing_lowerbound

    time = Benchmark.measure{
      @count_down.count
    }

    assert time.real.to_i == 10

  end

end

这是我的输出:

  

teamcity [enteredTheMatrix timestamp ='2017-09-28T15:10:11.470-0700']

     

teamcity [testCount count ='0'时间戳='2017-09-28T15:10:11.471-0700']完成0.00038s 0次测试,0   断言,0次失败,0次错误,0次跳过

     

处理完成,退出代码为0

知道什么是错的吗?它看起来很好。

1 个答案:

答案 0 :(得分:1)

测试应以前缀test_而不是testing_开头。使用错误的前缀使得MiniTest假设他们正在执行除运行测试之外的其他操作,因此它会忽略它们。