jcov 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/Gemfile +5 -0
- data/LICENSE +19 -0
- data/README.rdoc +109 -0
- data/Rakefile +2 -0
- data/bin/jcov +36 -0
- data/examples/jasmine/.gitignore +1 -0
- data/examples/jasmine/jasmine/ConsoleReporter.js +177 -0
- data/examples/jasmine/jasmine/MIT.LICENSE.txt +20 -0
- data/examples/jasmine/jasmine/jasmine.js +2476 -0
- data/examples/jasmine/jasmine/runner.js +28 -0
- data/examples/jasmine/javascripts/mean.js +11 -0
- data/examples/jasmine/jcov.yml +8 -0
- data/examples/jasmine/tests/mean_spec.js +15 -0
- data/examples/jspec/.gitignore +1 -0
- data/examples/jspec/javascripts/mean.js +11 -0
- data/examples/jspec/jcov.yml +8 -0
- data/examples/jspec/jspec/ext/slowness.js +43 -0
- data/examples/jspec/jspec/ext/trace.js +28 -0
- data/examples/jspec/jspec/lib/MIT.LICENSE.txt +7 -0
- data/examples/jspec/jspec/lib/jspec.js +1925 -0
- data/examples/jspec/jspec/runner.js +66 -0
- data/examples/jspec/tests/mean_spec.js +15 -0
- data/features/configuration.feature +134 -0
- data/features/coverage.feature +246 -0
- data/features/html_report.feature +130 -0
- data/features/javascript_interface.feature +72 -0
- data/features/reporting.feature +108 -0
- data/features/run.feature +217 -0
- data/features/step_definitions/report_steps.rb +54 -0
- data/features/support/env.rb +29 -0
- data/jcov.gemspec +29 -0
- data/lib/jcov.rb +11 -0
- data/lib/jcov/commands.rb +47 -0
- data/lib/jcov/configuration.rb +54 -0
- data/lib/jcov/coverage.rb +151 -0
- data/lib/jcov/reporter.rb +2 -0
- data/lib/jcov/reporter/console_reporter.rb +107 -0
- data/lib/jcov/reporter/file.html.erb +26 -0
- data/lib/jcov/reporter/html_reporter.rb +64 -0
- data/lib/jcov/reporter/report.css +53 -0
- data/lib/jcov/reporter/report.html.erb +45 -0
- data/lib/jcov/runner.rb +100 -0
- data/lib/jcov/version.rb +3 -0
- metadata +195 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
Feature: HTML Report
|
2
|
+
In order to know which exact lines are being executed
|
3
|
+
And to explore our source code
|
4
|
+
I want a persistant coverage report in HTML
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "public/javascripts/foo.js" with:
|
8
|
+
"""
|
9
|
+
// this is a comment
|
10
|
+
|
11
|
+
var one = "foo"; // 1
|
12
|
+
var z = 0; // 2
|
13
|
+
|
14
|
+
var two = function () { // 3
|
15
|
+
for (var i = 0; i < 10; i++) { // 4
|
16
|
+
z++; // 5
|
17
|
+
}
|
18
|
+
};
|
19
|
+
|
20
|
+
var three = function () { // 6
|
21
|
+
two(); // 7
|
22
|
+
};
|
23
|
+
|
24
|
+
"""
|
25
|
+
|
26
|
+
And a file named "public/javascripts/bar.js" with:
|
27
|
+
"""
|
28
|
+
var foo = 1;
|
29
|
+
var bar = 2;
|
30
|
+
var baz = 3;
|
31
|
+
"""
|
32
|
+
|
33
|
+
And a file named "test/javascripts/runner.js" with:
|
34
|
+
"""
|
35
|
+
load("public/javascripts/foo.js");
|
36
|
+
load("public/javascripts/bar.js");
|
37
|
+
error_count = 0;
|
38
|
+
"""
|
39
|
+
|
40
|
+
Scenario: reports to an HTML file
|
41
|
+
When I run `jcov --report`
|
42
|
+
Then a file named "jcov/report.html" should exist
|
43
|
+
|
44
|
+
Scenario: reports individual files to their own HTML files
|
45
|
+
When I run `jcov --report`
|
46
|
+
Then a file named "jcov/public/javascripts/foo.js.html" should exist
|
47
|
+
Then a file named "jcov/public/javascripts/bar.js.html" should exist
|
48
|
+
|
49
|
+
Scenario: it copies a css file
|
50
|
+
When I run `jcov --report`
|
51
|
+
Then a file named "jcov/report.css" should exist
|
52
|
+
|
53
|
+
Scenario: has a list of ran files
|
54
|
+
When I run `jcov --report`
|
55
|
+
And I open the report
|
56
|
+
Then I should see "public/javascripts/foo.js (4/7) 57%"
|
57
|
+
And I should see "public/javascripts/bar.js (3/3) 100%"
|
58
|
+
|
59
|
+
Scenario: shows the total coverage
|
60
|
+
When I run `jcov --report`
|
61
|
+
And I open the report
|
62
|
+
And I should see "Total: (7/10) 70%"
|
63
|
+
|
64
|
+
Scenario: shows the total coverage in the title
|
65
|
+
When I run `jcov --report`
|
66
|
+
And I open the report
|
67
|
+
And I should see "JCov : 70%"
|
68
|
+
|
69
|
+
Scenario: shows empty source files
|
70
|
+
Given a file named "public/javascripts/foo.js" with:
|
71
|
+
"""
|
72
|
+
// this is a comment
|
73
|
+
"""
|
74
|
+
When I run `jcov --report`
|
75
|
+
And I open the report
|
76
|
+
Then I should see "public/javascripts/foo.js (EMPTY) 100%"
|
77
|
+
|
78
|
+
Scenario: click through to an individual file's report
|
79
|
+
When I run `jcov --report`
|
80
|
+
And I open the report
|
81
|
+
And I click "public/javascripts/foo.js"
|
82
|
+
Then I should see "public/javascripts/foo.js"
|
83
|
+
|
84
|
+
Scenario: can click back to the index
|
85
|
+
When I run `jcov --report`
|
86
|
+
And I open the report
|
87
|
+
And I click "public/javascripts/foo.js"
|
88
|
+
And I click "JCov"
|
89
|
+
Then I should be on /report.html
|
90
|
+
|
91
|
+
Scenario: see a file-level coverage percentage
|
92
|
+
When I run `jcov --report`
|
93
|
+
And I open the report
|
94
|
+
And I click "public/javascripts/foo.js"
|
95
|
+
Then I should see "57%"
|
96
|
+
|
97
|
+
Scenario: see covered lines
|
98
|
+
When I run `jcov --report`
|
99
|
+
And I open the report
|
100
|
+
And I click "public/javascripts/foo.js"
|
101
|
+
Then I should see these lines covered:
|
102
|
+
| line |
|
103
|
+
| var one = "foo"; |
|
104
|
+
| var z = 0; |
|
105
|
+
| var two = function () { |
|
106
|
+
| var three = function () { |
|
107
|
+
|
108
|
+
Scenario: see uncovered lines
|
109
|
+
When I run `jcov --report`
|
110
|
+
And I open the report
|
111
|
+
And I click "public/javascripts/foo.js"
|
112
|
+
Then I should see these lines not covered:
|
113
|
+
| line |
|
114
|
+
| for (var i = 0; i < 10; i++) { |
|
115
|
+
| z++; |
|
116
|
+
| two(); |
|
117
|
+
|
118
|
+
Scenario: see uncoverable lines
|
119
|
+
When I run `jcov --report`
|
120
|
+
And I open the report
|
121
|
+
And I click "public/javascripts/foo.js"
|
122
|
+
Then I should see these lines uncoverable:
|
123
|
+
| line |
|
124
|
+
| // this is a comment |
|
125
|
+
|
126
|
+
Scenario: it escapes HTML entities
|
127
|
+
When I run `jcov --report`
|
128
|
+
And I open the report
|
129
|
+
And I click "public/javascripts/foo.js"
|
130
|
+
Then I should see "for (var i = 0; i < 10; i++)" in the HTML
|
@@ -0,0 +1,72 @@
|
|
1
|
+
Feature: javascript interface
|
2
|
+
In order for my javascript test framework to run inside of jcov
|
3
|
+
it needs to have a set of interface methods
|
4
|
+
|
5
|
+
Scenario: I want to print a line
|
6
|
+
Given a file named "test/javascripts/runner.js" with:
|
7
|
+
"""
|
8
|
+
println('foo');
|
9
|
+
println('bar');
|
10
|
+
"""
|
11
|
+
When I run `jcov`
|
12
|
+
Then the output should contain:
|
13
|
+
"""
|
14
|
+
foo
|
15
|
+
bar
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: I want to print a line without a carrage return
|
19
|
+
Given a file named "test/javascripts/runner.js" with:
|
20
|
+
"""
|
21
|
+
print('foo');
|
22
|
+
print('bar');
|
23
|
+
"""
|
24
|
+
When I run `jcov`
|
25
|
+
Then the output should contain:
|
26
|
+
"""
|
27
|
+
foobar
|
28
|
+
"""
|
29
|
+
|
30
|
+
Scenario: I want to print a single character
|
31
|
+
Given a file named "test/javascripts/runner.js" with:
|
32
|
+
"""
|
33
|
+
putc('.');
|
34
|
+
putc('.');
|
35
|
+
putc('.');
|
36
|
+
"""
|
37
|
+
When I run `jcov`
|
38
|
+
Then the output should contain:
|
39
|
+
"""
|
40
|
+
...
|
41
|
+
"""
|
42
|
+
|
43
|
+
Scenario: I want to read the contents of a file as a string
|
44
|
+
Given a file named "test/javascripts/runner.js" with:
|
45
|
+
"""
|
46
|
+
var contents = readFile('foo.txt');
|
47
|
+
print(contents);
|
48
|
+
"""
|
49
|
+
And a file named "foo.txt" with:
|
50
|
+
"""
|
51
|
+
foo contents
|
52
|
+
"""
|
53
|
+
When I run `jcov`
|
54
|
+
Then the output should contain:
|
55
|
+
"""
|
56
|
+
foo contents
|
57
|
+
"""
|
58
|
+
|
59
|
+
Scenario: I want to load a javascript file and have it executed
|
60
|
+
Given a file named "test/javascripts/runner.js" with:
|
61
|
+
"""
|
62
|
+
load("test.js");
|
63
|
+
"""
|
64
|
+
And a file named "test.js" with:
|
65
|
+
"""
|
66
|
+
print("here I am");
|
67
|
+
"""
|
68
|
+
When I run `jcov`
|
69
|
+
Then the output should contain:
|
70
|
+
"""
|
71
|
+
here I am
|
72
|
+
"""
|
@@ -0,0 +1,108 @@
|
|
1
|
+
Feature: reporting
|
2
|
+
In order to know how much of our code is being executed
|
3
|
+
I want to report coverage statistics
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "public/javascripts/foo.js" with:
|
7
|
+
"""
|
8
|
+
var one = "foo"; // 1
|
9
|
+
var z = 0; // 2
|
10
|
+
|
11
|
+
var two = function () { // 3
|
12
|
+
for (var i = 0; i < 10; i++) { // 4
|
13
|
+
z++; // 5
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
17
|
+
var three = function () { // 6
|
18
|
+
two(); // 7
|
19
|
+
};
|
20
|
+
|
21
|
+
"""
|
22
|
+
And a file named "test/javascripts/runner.js" with:
|
23
|
+
"""
|
24
|
+
load("public/javascripts/foo.js");
|
25
|
+
error_count = 0;
|
26
|
+
"""
|
27
|
+
|
28
|
+
Scenario: does not show a console coverage report unless asked
|
29
|
+
When I run `jcov`
|
30
|
+
Then the output should not contain:
|
31
|
+
"""
|
32
|
+
Coverage Report
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario: shows a console coverage report when asked
|
36
|
+
When I run `jcov --report`
|
37
|
+
Then the output should contain:
|
38
|
+
"""
|
39
|
+
Coverage Report
|
40
|
+
"""
|
41
|
+
And the output should match:
|
42
|
+
"""
|
43
|
+
public/javascripts/foo.js\s+\(4/7\)\s+57%
|
44
|
+
"""
|
45
|
+
|
46
|
+
Scenario: reports on multiple files
|
47
|
+
Given a file named "public/javascripts/bar.js" with:
|
48
|
+
"""
|
49
|
+
var foo = 1;
|
50
|
+
var bar = 2;
|
51
|
+
var baz = 3;
|
52
|
+
"""
|
53
|
+
When I run `jcov --report`
|
54
|
+
Then the output should match:
|
55
|
+
"""
|
56
|
+
public/javascripts/foo.js\s+\(4/7\)\s+57%
|
57
|
+
"""
|
58
|
+
And the output should match:
|
59
|
+
"""
|
60
|
+
public/javascripts/bar.js\s+\(0/3\)\s+0%
|
61
|
+
"""
|
62
|
+
|
63
|
+
Scenario: only report on files actually run if --test is provided
|
64
|
+
Given a file named "public/javascripts/bar.js" with:
|
65
|
+
"""
|
66
|
+
var foo = 1;
|
67
|
+
var bar = 2;
|
68
|
+
var baz = 3;
|
69
|
+
"""
|
70
|
+
When I run `jcov --report --test foo`
|
71
|
+
Then the output should match:
|
72
|
+
"""
|
73
|
+
public/javascripts/foo.js\s+\(4/7\)\s+57%
|
74
|
+
"""
|
75
|
+
And the output should not contain:
|
76
|
+
"""
|
77
|
+
public/javascripts/bar.js
|
78
|
+
"""
|
79
|
+
|
80
|
+
Scenario: does not report on the runner if it's in the scripts directory
|
81
|
+
Given a file named "public/javascripts/runner.js" with:
|
82
|
+
"""
|
83
|
+
load("public/javascripts/foo.js");
|
84
|
+
error_count = 0;
|
85
|
+
"""
|
86
|
+
And a file named "jcov.yml" with:
|
87
|
+
"""
|
88
|
+
test_runner: public/javascripts/runner.js
|
89
|
+
"""
|
90
|
+
When I run `jcov --report`
|
91
|
+
Then the output should match:
|
92
|
+
"""
|
93
|
+
public/javascripts/foo.js\s+\(4/7\)\s+57%
|
94
|
+
"""
|
95
|
+
And the output should not contain:
|
96
|
+
"""
|
97
|
+
public/javascripts/runner.js
|
98
|
+
"""
|
99
|
+
|
100
|
+
Scenario: reports files as empty
|
101
|
+
Given a file named "public/javascripts/bar.js" with:
|
102
|
+
"""
|
103
|
+
"""
|
104
|
+
When I run `jcov --report`
|
105
|
+
Then the output should match:
|
106
|
+
"""
|
107
|
+
public/javascripts/bar.js\s+\(EMPTY\)\s+100%
|
108
|
+
"""
|
@@ -0,0 +1,217 @@
|
|
1
|
+
Feature: test runner
|
2
|
+
In order to test my Javascript without opening a browser
|
3
|
+
I want to use a tool that runs my tests headless.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "public/javascripts/foo.js" with:
|
7
|
+
"""
|
8
|
+
var z = 0;
|
9
|
+
"""
|
10
|
+
|
11
|
+
Scenario: runs the runner.js file
|
12
|
+
Given a file named "test/javascripts/runner.js" with:
|
13
|
+
"""
|
14
|
+
load("public/javascripts/foo.js");
|
15
|
+
println('foo');
|
16
|
+
"""
|
17
|
+
When I run `jcov`
|
18
|
+
Then the output should contain:
|
19
|
+
"""
|
20
|
+
foo
|
21
|
+
"""
|
22
|
+
|
23
|
+
Scenario: reports success
|
24
|
+
Given a file named "test/javascripts/runner.js" with:
|
25
|
+
"""
|
26
|
+
error_count = 0;
|
27
|
+
"""
|
28
|
+
When I run `jcov`
|
29
|
+
Then the output should not contain:
|
30
|
+
"""
|
31
|
+
Test Failures! :(
|
32
|
+
"""
|
33
|
+
And the exit status should be 0
|
34
|
+
|
35
|
+
Scenario: reports the failures
|
36
|
+
Given a file named "test/javascripts/runner.js" with:
|
37
|
+
"""
|
38
|
+
error_count = 3;
|
39
|
+
"""
|
40
|
+
When I run `jcov`
|
41
|
+
Then the output should contain:
|
42
|
+
"""
|
43
|
+
Test Failures! :(
|
44
|
+
"""
|
45
|
+
And the exit status should not be 0
|
46
|
+
|
47
|
+
Scenario: provides the test framework the set of tests to run
|
48
|
+
Given a file named "test/javascripts/runner.js" with:
|
49
|
+
"""
|
50
|
+
error_count = 0;
|
51
|
+
var t = JCov.tests;
|
52
|
+
for (var i = 0; i < t.length; i++) {
|
53
|
+
println(t[i]);
|
54
|
+
}
|
55
|
+
"""
|
56
|
+
And an empty file named "test/javascripts/foo_test.js"
|
57
|
+
And an empty file named "test/javascripts/wazzle/bar_test.js"
|
58
|
+
When I run `jcov`
|
59
|
+
Then the output should contain:
|
60
|
+
"""
|
61
|
+
test/javascripts/foo_test.js
|
62
|
+
test/javascripts/wazzle/bar_test.js
|
63
|
+
"""
|
64
|
+
And the output should not contain:
|
65
|
+
"""
|
66
|
+
test/javascripts/runner.js
|
67
|
+
"""
|
68
|
+
|
69
|
+
Scenario: allows the user to run a focused test
|
70
|
+
Given a file named "test/javascripts/runner.js" with:
|
71
|
+
"""
|
72
|
+
error_count = 0;
|
73
|
+
var t = JCov.tests;
|
74
|
+
for (var i = 0; i < t.length; i++) {
|
75
|
+
println(t[i]);
|
76
|
+
}
|
77
|
+
"""
|
78
|
+
And an empty file named "test/javascripts/foo_test.js"
|
79
|
+
And an empty file named "test/javascripts/wazzle/bar_test.js"
|
80
|
+
When I run `jcov --test test/javascripts/wazzle/bar_test.js`
|
81
|
+
Then the output should contain:
|
82
|
+
"""
|
83
|
+
test/javascripts/wazzle/bar_test.js
|
84
|
+
"""
|
85
|
+
And the output should not contain:
|
86
|
+
"""
|
87
|
+
test/javascripts/foo_test.js
|
88
|
+
"""
|
89
|
+
|
90
|
+
Scenario: allows the user to run a focused test without the --test switch
|
91
|
+
Given a file named "test/javascripts/runner.js" with:
|
92
|
+
"""
|
93
|
+
error_count = 0;
|
94
|
+
var t = JCov.tests;
|
95
|
+
for (var i = 0; i < t.length; i++) {
|
96
|
+
println(t[i]);
|
97
|
+
}
|
98
|
+
"""
|
99
|
+
And an empty file named "test/javascripts/foo_test.js"
|
100
|
+
And an empty file named "test/javascripts/wazzle/bar_test.js"
|
101
|
+
When I run `jcov test/javascripts/wazzle/bar_test.js`
|
102
|
+
Then the output should contain:
|
103
|
+
"""
|
104
|
+
test/javascripts/wazzle/bar_test.js
|
105
|
+
"""
|
106
|
+
And the output should not contain:
|
107
|
+
"""
|
108
|
+
test/javascripts/foo_test.js
|
109
|
+
"""
|
110
|
+
|
111
|
+
Scenario: allows the user to run multiple focused tests
|
112
|
+
Given a file named "test/javascripts/runner.js" with:
|
113
|
+
"""
|
114
|
+
error_count = 0;
|
115
|
+
var t = JCov.tests;
|
116
|
+
for (var i = 0; i < t.length; i++) {
|
117
|
+
println(t[i]);
|
118
|
+
}
|
119
|
+
"""
|
120
|
+
And an empty file named "test/javascripts/foo_test.js"
|
121
|
+
And an empty file named "test/javascripts/wazzle/bar_test.js"
|
122
|
+
And an empty file named "test/javascripts/furble/baz_test.js"
|
123
|
+
When I run `jcov test/javascripts/wazzle/bar_test.js test/javascripts/furble/baz_test.js`
|
124
|
+
Then the output should contain:
|
125
|
+
"""
|
126
|
+
test/javascripts/furble/baz_test.js
|
127
|
+
test/javascripts/wazzle/bar_test.js
|
128
|
+
"""
|
129
|
+
And the output should not contain:
|
130
|
+
"""
|
131
|
+
test/javascripts/foo_test.js
|
132
|
+
"""
|
133
|
+
|
134
|
+
Scenario: allows the user to match tests with a regex
|
135
|
+
Given a file named "test/javascripts/runner.js" with:
|
136
|
+
"""
|
137
|
+
error_count = 0;
|
138
|
+
var t = JCov.tests;
|
139
|
+
for (var i = 0; i < t.length; i++) {
|
140
|
+
println(t[i]);
|
141
|
+
}
|
142
|
+
"""
|
143
|
+
And an empty file named "test/javascripts/foo_test.js"
|
144
|
+
And an empty file named "test/javascripts/wazzle/bar_test.js"
|
145
|
+
When I run `jcov --test "wa[z]{2}le"`
|
146
|
+
Then the output should contain:
|
147
|
+
"""
|
148
|
+
test/javascripts/wazzle/bar_test.js
|
149
|
+
"""
|
150
|
+
And the output should not contain:
|
151
|
+
"""
|
152
|
+
test/javascripts/foo_test.js
|
153
|
+
"""
|
154
|
+
|
155
|
+
Scenario: configuration is available to the javascript context
|
156
|
+
Given a file named "jcov.yml" with:
|
157
|
+
"""
|
158
|
+
threshold: 33
|
159
|
+
"""
|
160
|
+
And a file named "test/javascripts/runner.js" with:
|
161
|
+
"""
|
162
|
+
error_count = 0;
|
163
|
+
println(JCov.config.threshold);
|
164
|
+
"""
|
165
|
+
When I run `jcov`
|
166
|
+
Then the output should contain:
|
167
|
+
"""
|
168
|
+
33
|
169
|
+
"""
|
170
|
+
|
171
|
+
Scenario: user can enable verbose mode
|
172
|
+
Given a file named "test/javascripts/runner.js" with:
|
173
|
+
"""
|
174
|
+
error_count = 0;
|
175
|
+
println(JCov.options.verbose);
|
176
|
+
"""
|
177
|
+
When I run `jcov --verbose`
|
178
|
+
Then the output should contain:
|
179
|
+
"""
|
180
|
+
true
|
181
|
+
"""
|
182
|
+
|
183
|
+
Scenario: user can disable color output
|
184
|
+
Given a file named "test/javascripts/runner.js" with:
|
185
|
+
"""
|
186
|
+
error_count = 0;
|
187
|
+
println(JCov.options.color);
|
188
|
+
"""
|
189
|
+
When I run `jcov --no-color`
|
190
|
+
Then the output should contain:
|
191
|
+
"""
|
192
|
+
false
|
193
|
+
"""
|
194
|
+
|
195
|
+
Scenario: user can enable color output
|
196
|
+
Given a file named "test/javascripts/runner.js" with:
|
197
|
+
"""
|
198
|
+
error_count = 0;
|
199
|
+
println(JCov.options.color);
|
200
|
+
"""
|
201
|
+
When I run `jcov --color`
|
202
|
+
Then the output should contain:
|
203
|
+
"""
|
204
|
+
true
|
205
|
+
"""
|
206
|
+
|
207
|
+
Scenario: color defaults to off in a non-interactive shell (which cucumber is)
|
208
|
+
Given a file named "test/javascripts/runner.js" with:
|
209
|
+
"""
|
210
|
+
error_count = 0;
|
211
|
+
println(JCov.options.color);
|
212
|
+
"""
|
213
|
+
When I run `jcov`
|
214
|
+
Then the output should contain:
|
215
|
+
"""
|
216
|
+
false
|
217
|
+
"""
|