@@ -198,4 +198,44 @@ defmodule ExCoveralls.CoberturaTest do
198
198
assert String . ends_with? ( source1 , "/lib" )
199
199
assert String . ends_with? ( source2 , "/test/fixtures" )
200
200
end
201
+
202
+ test_with_mock "generate cobertura file with defprotocol" , _ , ExCoveralls.Settings , [ ] ,
203
+ get_coverage_options: fn -> % { "output_dir" => @ test_output_dir } end ,
204
+ get_file_col_width: fn -> 40 end ,
205
+ get_print_summary: fn -> true end ,
206
+ get_print_files: fn -> true end do
207
+ content = "defprotocol TestProtocol do\n def test(value)\n end\n "
208
+ counts = [ 0 , 1 , nil , nil ]
209
+ source_info = [ % { name: "test/fixtures/test_protocol.ex" , source: content , coverage: counts } ]
210
+
211
+ stats_result =
212
+ "" <>
213
+ "----------------\n " <>
214
+ "COV FILE LINES RELEVANT MISSED\n " <>
215
+ " 50.0% test/fixtures/test_protocol.ex 4 2 1\n " <>
216
+ "[TOTAL] 50.0%\n " <>
217
+ "----------------\n "
218
+
219
+ assert capture_io ( fn -> Cobertura . execute ( source_info ) end ) =~ stats_result
220
+ end
221
+
222
+ test_with_mock "generate cobertura file with defimpl" , _ , ExCoveralls.Settings , [ ] ,
223
+ get_coverage_options: fn -> % { "output_dir" => @ test_output_dir } end ,
224
+ get_file_col_width: fn -> 40 end ,
225
+ get_print_summary: fn -> true end ,
226
+ get_print_files: fn -> true end do
227
+ content = "defimpl TestProtocol, for: Integer do\n def test(value), do: \" integer!\" \n end\n "
228
+ counts = [ 0 , 1 , nil , nil ]
229
+ source_info = [ % { name: "test/fixtures/test_impl.ex" , source: content , coverage: counts } ]
230
+
231
+ stats_result =
232
+ "" <>
233
+ "----------------\n " <>
234
+ "COV FILE LINES RELEVANT MISSED\n " <>
235
+ " 50.0% test/fixtures/test_impl.ex 4 2 1\n " <>
236
+ "[TOTAL] 50.0%\n " <>
237
+ "----------------\n "
238
+
239
+ assert capture_io ( fn -> Cobertura . execute ( source_info ) end ) =~ stats_result
240
+ end
201
241
end
0 commit comments