/
test_heckle_runner.rb
54 lines (42 loc) · 1.32 KB
/
test_heckle_runner.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'minitest/autorun'
require 'heckle_runner'
# Tests needed:
# * if no method, loads all local methods
# * should raise an exception if the class/module can't be found
# * should raise an exception if the method can't be found
# * Tests for option parsing.
class TestHeckleRunnerRun < MiniTest::Unit::TestCase
@@dummy_dir = File.expand_path('test/fixtures/minitest_project')
dummy_lib = File.join(@@dummy_dir, 'lib')
$LOAD_PATH << dummy_lib
def setup
super
@old_pwd = Dir.pwd
Dir.chdir @@dummy_dir
# See MiniTest's test/minitest/metametameta.rb
@output = StringIO.new("")
MiniTest::Unit::TestCase.reset
MiniTest::Unit.output = @output
end
def teardown
super
Dir.chdir @old_pwd
MiniTest::Unit.output = $stdout
MiniTest::Unit::TestCase.test_suites.each do |test|
Object.send :remove_const, test.to_s.to_sym
end
end
def test_run_with_full_coverage
out, _ = capture_io do
HeckleRunner.run %w[Doubler double]
end
assert_match %r{No mutants survived.}, out
end
def test_run_with_partial_coverage
out, _ = capture_io do
HeckleRunner.run %w[Doubler double --tests test/test_doubler_with_a_number.rb]
end
assert_match %r{The following mutations didn't cause test failures:}, out
refute_match %{No mutants survived.}, out
end
end