micro_test 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.md +73 -0
  2. data/bin/mt +2 -2
  3. data/lib/micro_test.rb +3 -17
  4. metadata +2 -3
  5. data/Gemfile +0 -2
  6. data/Gemfile.lock +0 -10
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # MicroTest
2
+
3
+ ### Testing should be simple.
4
+
5
+ It bothers me that testing frameworks never seem to resist
6
+ the slippery slope of feature creep and eventually become an end unto themselves.
7
+ MiniTest is a step in the right direction, but still feels bigger than it should.
8
+
9
+ #### MicroTest is an experiment to see just how simple a testing "framework" can be.
10
+
11
+ ## Features
12
+
13
+ * __Opinionated & small__ - _only 70 lines of code_
14
+ * __Only one assertion: `assert`__ - _since this is the heart of testing_
15
+ * __Tests run in random order__ - _to prevent the bad practice of run order depenencies_
16
+ * __Plays nice with others__ - _easy to introduce to an existing code base_
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ gem install micro_test
22
+ ```
23
+
24
+ ## API
25
+
26
+ * Tests subclass `MicroTest::Test`
27
+ * Define tests with `test "description" do ...`
28
+ * Assert statements with `assert [statement]`
29
+ * Run tests with `$mt /path/to/test_file_or_dir` or `MicroTest::Runner.run` from code
30
+
31
+ That's all there is to learn.
32
+
33
+ ## Examples
34
+
35
+ Define a test.
36
+
37
+ ```ruby
38
+ # /example/test/math_test.rb
39
+ class MathTest < MicroTest::Test
40
+
41
+ test "addition" do
42
+ assert 2 + 2 == 4
43
+ end
44
+
45
+ test "subtraction" do
46
+ assert 2 - 2 == 0
47
+ end
48
+
49
+ test "multiplication" do
50
+ assert 2 * 2 == 4
51
+ end
52
+
53
+ test "division" do
54
+ assert 2 / 2 == 1 # add a trailing comment if you want a message
55
+ end
56
+
57
+ # and one failing test
58
+ test "fail" do
59
+ assert 2 + 2 == 5
60
+ end
61
+
62
+ end
63
+ ```
64
+
65
+ Run the tests.
66
+
67
+ ```bash
68
+ $ mt /example/test
69
+ ```
70
+
71
+ Test output.
72
+
73
+ ![MicroTest output](http://hopsoft.github.com/micro_test/images/micro_test.png)
data/bin/mt CHANGED
@@ -3,7 +3,7 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "micro_test"))
4
4
 
5
5
  path = ARGV[0].to_s.strip
6
- path = File.expand_path(File.dirname(__FILE__)) if path.empty?
6
+ path = Dir.pwd if path.empty?
7
7
 
8
8
  if path == "-h" || path == "--help"
9
9
  puts "Runs MicroTest on the provided path."
@@ -12,7 +12,7 @@ if path == "-h" || path == "--help"
12
12
  exit
13
13
  end
14
14
 
15
- path = File.expand_path(File.join(__FILE__), path) unless File.exist?(path)
15
+ path = File.join(Dir.pwd, path) unless path =~ /^\//
16
16
  unless File.exist?(path)
17
17
  puts "#{path} not found."
18
18
  puts "Please check the path and try again."
data/lib/micro_test.rb CHANGED
@@ -32,16 +32,16 @@ module MicroTest
32
32
 
33
33
  def self.run
34
34
  @passed = @failed = 0
35
- test_classes.each do |test_class|
35
+ test_classes.shuffle.each do |test_class|
36
36
  before = test_class.callbacks[:before]
37
37
  after = test_class.callbacks[:after]
38
38
 
39
39
  puts test_class.name
40
40
  before[:all].call if before[:all]
41
- test_class.tests.each do |desc, block|
41
+ test_class.tests.keys.shuffle.each do |desc|
42
42
  before[:each].call if before[:each]
43
43
  puts "- test #{desc}"
44
- block.call
44
+ test_class.tests[desc].call
45
45
  after[:each].call if after[:each]
46
46
  end
47
47
  after[:all].call if after[:all]
@@ -82,17 +82,3 @@ module MicroTest
82
82
  end
83
83
  end
84
84
  end
85
-
86
- # class ExampleTest < MicroTest::Test
87
- # test "booleans" do
88
- # assert 1 == 1
89
- # assert true # should be true
90
- # assert false
91
- # end
92
-
93
- # test "foobar" do
94
- # assert 5 - 2 == 10 # math works
95
- # end
96
- # end
97
-
98
- # MicroTest::Runner.run
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -23,8 +23,7 @@ extra_rdoc_files: []
23
23
  files:
24
24
  - lib/micro_test.rb
25
25
  - bin/mt
26
- - Gemfile
27
- - Gemfile.lock
26
+ - README.md
28
27
  homepage: https://github.com/hopsoft/micro_test
29
28
  licenses:
30
29
  - MIT
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source :rubygems
2
- gem "micro_test"
data/Gemfile.lock DELETED
@@ -1,10 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- micro_test (0.0.4)
5
-
6
- PLATFORMS
7
- ruby
8
-
9
- DEPENDENCIES
10
- micro_test