micro_test 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -99
- metadata +1 -1
data/README.md
CHANGED
@@ -2,40 +2,26 @@
|
|
2
2
|
|
3
3
|
## Ruby's no-nonsense testing framework
|
4
4
|
|
5
|
-
|
5
|
+
### Quick Start
|
6
6
|
|
7
|
-
|
8
|
-
MicroTest avoids this pitfall with a relentless focus on simplicity.
|
7
|
+
Install
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
* __Simplicity__
|
15
|
-
A tiny API with only 4 methods. You'll be up and running faster than ever before.
|
16
|
-
* __Only 1 Assert Method__
|
17
|
-
Forget the copious expections and assert methods from other frameworks and start focusing on what really matters.
|
18
|
-
* __Small Footprint__
|
19
|
-
Weighs in around 140 lines of code. Less code means less to learn and less that can go wrong.
|
20
|
-
* __Plays Nice__
|
21
|
-
Runs side by side with other test frameworks which makes it easy to integrate into existing projects.
|
22
|
-
* __Random Run Order__
|
23
|
-
Prevents the bad practice of run order dependencies by running tests in random order.
|
24
|
-
* __Customizable
|
25
|
-
Output__ Customize test output with pluggable formatters, or give back by writing your own.
|
26
|
-
|
27
|
-
## Quick Start
|
9
|
+
```bash
|
10
|
+
$ gem install micro_test
|
11
|
+
```
|
28
12
|
|
29
|
-
|
13
|
+
Experiment
|
30
14
|
|
31
15
|
```bash
|
32
|
-
$
|
16
|
+
$ mt --demo
|
17
|
+
$ mt --help
|
33
18
|
```
|
34
19
|
|
35
|
-
|
20
|
+
Write
|
36
21
|
|
37
22
|
```ruby
|
38
23
|
require 'micro_test'
|
24
|
+
|
39
25
|
class MyTest < MicroTest::Test
|
40
26
|
test "some assumption" do
|
41
27
|
assert true
|
@@ -43,83 +29,10 @@ class MyTest < MicroTest::Test
|
|
43
29
|
end
|
44
30
|
```
|
45
31
|
|
46
|
-
|
32
|
+
Run
|
47
33
|
|
48
34
|
```bash
|
49
35
|
$ mt
|
50
36
|
```
|
51
37
|
|
52
|
-
|
53
|
-
|
54
|
-
* `MicroTest::Test` Superclass for all tests.
|
55
|
-
* `test(desc, &block)` Defines a test method.
|
56
|
-
* `desc` - a description of what is being tested
|
57
|
-
* `&block` - a block of code which defines the test
|
58
|
-
|
59
|
-
* `assert(value)` Verifies the truthiness of a value.
|
60
|
-
* `value` - the value to assert
|
61
|
-
|
62
|
-
* `before(what, &block)` A callback that runs before the specified 'what'.
|
63
|
-
* `what` - indicates the callback type
|
64
|
-
* `:all` - runs before all tests in the class
|
65
|
-
* `:each` - runse before each test in the class
|
66
|
-
* `&block` - the block of code to execute
|
67
|
-
|
68
|
-
* `after(what, &block)` A callback that runs after the specified 'what'.
|
69
|
-
* `what` - indicates the callback type
|
70
|
-
* `:all` - runs after all tests in the class
|
71
|
-
* `:each` - runse after each test in the class
|
72
|
-
* `&block` - the block of code to execute
|
73
|
-
|
74
|
-
## Example
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
# /example/test/math_test.rb
|
78
|
-
class MathTest < MicroTest::Test
|
79
|
-
|
80
|
-
before :all do
|
81
|
-
# runs once before all tests
|
82
|
-
end
|
83
|
-
|
84
|
-
before :each do
|
85
|
-
# runs before each test
|
86
|
-
end
|
87
|
-
|
88
|
-
test "addition" do
|
89
|
-
assert 2 + 2 == 4
|
90
|
-
end
|
91
|
-
|
92
|
-
test "subtraction" do
|
93
|
-
assert 2 - 2 == 0
|
94
|
-
end
|
95
|
-
|
96
|
-
test "multiplication" do
|
97
|
-
assert 2 * 2 == 4
|
98
|
-
end
|
99
|
-
|
100
|
-
test "division" do
|
101
|
-
assert 2 / 2 == 1 # add a trailing comment if you want a message
|
102
|
-
end
|
103
|
-
|
104
|
-
# and one failing test
|
105
|
-
test "fail" do
|
106
|
-
assert 2 + 2 == 5
|
107
|
-
end
|
108
|
-
|
109
|
-
after :each do
|
110
|
-
# runs after each test
|
111
|
-
end
|
112
|
-
|
113
|
-
after :all do
|
114
|
-
# runs once after all tests
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
```
|
119
|
-
|
120
|
-
Run tests.
|
121
|
-
|
122
|
-
```bash
|
123
|
-
$ mt
|
124
|
-
$ mt -p /example/test
|
125
|
-
$ mt -p /example/test/math_test.rb
|
38
|
+
[See the product page for more details.](http://hopsoft.github.com/micro_test/)
|