44??дRuby?????????
???????????? ???????[ 2012/3/9 11:14:27 ] ????????
1 true.should == true
2 5.should == 5
?????????????????????should???????????????£?
1 class Object
2 def should
3 self
4 end
5 end ????
????????????????????????(??????????????);????????????ò?????????????????
???????????Σ???????????????????????????????????????????????????????????????????У???????????????????????????????????????????????檔??????????????????е????????????????????????????44?д???
1 module Kernel
2 def describe(description?? &block)
3 tests = Dsl.new.parse(description?? block)
4 tests.execute
5 end
6 end
7 class Object
8 def should
9 self
10 end
11 end
12 class Dsl
13 def initialize
14 @tests = {}
15 end
16 def parse(description?? block)
17 self.instance_eval(&block)
18 Executor.new(description?? @tests)
19 end
20 def it(description?? &block)
21 @tests[description] = block
22 end
23 end
24 class Executor
25 def initialize(description?? tests)
26 @description = description
27 @tests = tests
28 @success_count = 0
29 @failure_count = 0
30 end
31 def execute
32 puts "#{@description}"
33 @tests.each_pair do |name?? block|
34 print " - #{name}"
35 result = self.instance_eval(&block)
36 result ? @success_count += 1 : @failure_count += 1
37 puts result ? " SUCCESS" : " FAILURE"
38 end
39 summary
40 end
41 def summary
42 puts "
#{@tests.keys.size} tests?? #{@success_count} success?? #{@failure_count} failure"
43 end
44 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