@@ -22,38 +22,42 @@ class CoberturaXmlWriterTest extends FunSuite with BeforeAndAfter with OneInstan
22
22
23
23
def fileIn (dir : File ) = new File (dir, " cobertura.xml" )
24
24
25
+ // Let current directory be our source root
26
+ private val sourceRoot = new File (" ." )
27
+ private def canonicalPath (fileName : String ) = new File (sourceRoot, fileName).getCanonicalPath
28
+
25
29
test(" cobertura output validates" ) {
26
30
27
31
val dir = tempDir()
28
32
29
33
val coverage = scoverage.Coverage ()
30
34
coverage
31
- .add(Statement (" a.scala" , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create" , " " ),
35
+ .add(Statement (canonicalPath( " a.scala" ) , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create" , canonicalPath( " a.scala " ) ),
32
36
1 , 2 , 3 , 12 , " " , " " , " " , false , 3 ))
33
37
coverage
34
- .add(Statement (" a.scala" , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create2" , " " ),
38
+ .add(Statement (canonicalPath( " a.scala" ) , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create2" , canonicalPath( " a.scala " ) ),
35
39
2 , 2 , 3 , 16 , " " , " " , " " , false , 3 ))
36
40
coverage
37
- .add(Statement (" b.scala" , Location (" com.sksamuel.scoverage2" , " B" , " B" , ClassType .Object , " retrieve" , " " ),
41
+ .add(Statement (canonicalPath( " b.scala" ) , Location (" com.sksamuel.scoverage2" , " B" , " B" , ClassType .Object , " retrieve" , canonicalPath( " b.scala " ) ),
38
42
3 , 2 , 3 , 21 , " " , " " , " " , false , 0 ))
39
43
coverage
40
- .add(Statement (" b.scala" ,
41
- Location (" com.sksamuel.scoverage2" , " B" , " B" , ClassType .Object , " retrieve2" , " " ),
44
+ .add(Statement (canonicalPath( " b.scala" ) ,
45
+ Location (" com.sksamuel.scoverage2" , " B" , " B" , ClassType .Object , " retrieve2" , canonicalPath( " b.scala " ) ),
42
46
4 , 2 , 3 , 9 , " " , " " , " " , false , 3 ))
43
47
coverage
44
- .add(Statement (" c.scala" , Location (" com.sksamuel.scoverage3" , " C" , " C" , ClassType .Object , " update" , " " ),
48
+ .add(Statement (canonicalPath( " c.scala" ) , Location (" com.sksamuel.scoverage3" , " C" , " C" , ClassType .Object , " update" , canonicalPath( " c.scala " ) ),
45
49
5 , 2 , 3 , 66 , " " , " " , " " , true , 3 ))
46
50
coverage
47
- .add(Statement (" c.scala" , Location (" com.sksamuel.scoverage3" , " C" , " C" , ClassType .Object , " update2" , " " ),
51
+ .add(Statement (canonicalPath( " c.scala" ) , Location (" com.sksamuel.scoverage3" , " C" , " C" , ClassType .Object , " update2" , canonicalPath( " c.scala " ) ),
48
52
6 , 2 , 3 , 6 , " " , " " , " " , true , 3 ))
49
53
coverage
50
- .add(Statement (" d.scala" , Location (" com.sksamuel.scoverage4" , " D" , " D" , ClassType .Object , " delete" , " " ),
54
+ .add(Statement (canonicalPath( " d.scala" ) , Location (" com.sksamuel.scoverage4" , " D" , " D" , ClassType .Object , " delete" , canonicalPath( " d.scala " ) ),
51
55
7 , 2 , 3 , 4 , " " , " " , " " , false , 0 ))
52
56
coverage
53
- .add(Statement (" d.scala" , Location (" com.sksamuel.scoverage4" , " D" , " D" , ClassType .Object , " delete2" , " " ),
57
+ .add(Statement (canonicalPath( " d.scala" ) , Location (" com.sksamuel.scoverage4" , " D" , " D" , ClassType .Object , " delete2" , canonicalPath( " d.scala " ) ),
54
58
8 , 2 , 3 , 14 , " " , " " , " " , false , 0 ))
55
59
56
- val writer = new CoberturaXmlWriter (new File ( " " ) , dir)
60
+ val writer = new CoberturaXmlWriter (sourceRoot , dir)
57
61
writer.write(coverage)
58
62
59
63
val domFactory = DocumentBuilderFactory .newInstance()
@@ -83,16 +87,16 @@ class CoberturaXmlWriterTest extends FunSuite with BeforeAndAfter with OneInstan
83
87
84
88
val coverage = Coverage ()
85
89
coverage
86
- .add(Statement (" a.scala" , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create" , " " ),
90
+ .add(Statement (canonicalPath( " a.scala" ) , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create" , canonicalPath( " a.scala " ) ),
87
91
1 , 2 , 3 , 12 , " " , " " , " " , false ))
88
92
coverage
89
- .add(Statement (" a.scala" , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create2" , " " ),
93
+ .add(Statement (canonicalPath( " a.scala" ) , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create2" , canonicalPath( " a.scala " ) ),
90
94
2 , 2 , 3 , 16 , " " , " " , " " , true ))
91
95
coverage
92
- .add(Statement (" a.scala" , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create3" , " " ),
96
+ .add(Statement (canonicalPath( " a.scala" ) , Location (" com.sksamuel.scoverage" , " A" , " A" , ClassType .Object , " create3" , canonicalPath( " a.scala " ) ),
93
97
3 , 3 , 3 , 20 , " " , " " , " " , true , 1 ))
94
98
95
- val writer = new CoberturaXmlWriter (new File ( " " ) , dir)
99
+ val writer = new CoberturaXmlWriter (sourceRoot , dir)
96
100
writer.write(coverage)
97
101
98
102
val xml = XML .loadFile(fileIn(dir))
0 commit comments