44??дRuby?????????
???????????? ???????[ 2012/3/27 10:36:28 ] ????????
???????????Σ???????????????????????????????????????????????????????????????????У???????????????????????????????????????????????檔??????????????????е????????????????????????????44?д???
module Kernel
def describe(description?? &block)
tests = Dsl.new.parse(description?? block)
tests.execute
end
end
class Object
def should
self
end
end
class Dsl
def initialize
@tests = {}
end
def parse(description?? block)
self.instance_eval(&block)
Executor.new(description?? @tests)
end
def it(description?? &block)
@tests[description] = block
end
end
class Executor
def initialize(description?? tests)
@description = description
@tests = tests
@success_count = 0
@failure_count = 0
end
def execute
puts "#{@description}"
@tests.each_pair do |name?? block|
print " - #{name}"
result = self.instance_eval(&block)
result ? @success_count += 1 : @failure_count += 1
puts result ? " SUCCESS" : " FAILURE"
end
summary
end
def summary
puts "
#{@tests.keys.size} tests?? #{@success_count} success?? #{@failure_count} failure"
end
????????????????????????????г??????????????????????????????
????some test
????- should be true SUCCESS
????- should show that an expression can be true SUCCESS
????- should be failing deliberately FAILURE
????3 tests?? 2 success?? 1 failure
????????????????????????????????????????????????????д??????????5???????????????????????????????????????????????Щ???????????????????????????API??????????????????????????????????????????????????????????????е??Щ????????磬????????DSL??????????????С??????????????????????????bacon ?????????????д????????Rspec???????檔???д??Attest????????????????????????????????????????:P???????????????κ??????test double ?????????????????????????????test double????
?????????Test Double??????????С?????????????????????????????????Test Stub???????????Mock Object??Test Spy??Fake Object??Dummy Object??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11