Skip to content

Commit

Permalink
workaround for Winter 19 SFDC Bug: blank locationsNotCovered returned…
Browse files Browse the repository at this point in the history
… from REST: /tooling/runTestsSynchronous/

previously JSON parsing would fail because locationsNotCovered is supposed to contain non blank data
  • Loading branch information
neowit committed Nov 5, 2018
1 parent 2c92d9d commit eb9b1a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ object RunTestJsonSupport {

case class TestCodeCoverage(numLocationsNotCovered: Option[Int],
name: Option[String],
methodInfo: List[MethodInfo],
dmlInfo: List[DmlInfo],
methodInfo: Option[List[MethodInfo]],
dmlInfo: Option[List[DmlInfo]],
numLocations: Option[Int],
soqlInfo: List[SoqlInfo],
soqlInfo: Option[List[SoqlInfo]],
id: Option[String],
soslInfo: List[SoslInfo],
locationsNotCovered: List[CodeLocation],
soslInfo: Option[List[SoslInfo]],
locationsNotCovered: Option[List[CodeLocation]],
`type`: Option[String],
namespace: Option[String]
)
Expand Down
13 changes: 10 additions & 3 deletions src/main/scala/com/neowit/response/protocols/vim/RunTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,19 @@ object RunTests extends JsonSupport {
val coverageWriter = new PrintWriter(coverageFile)
for (coverage <- coverageReport.coveragePerFile) {
val locations = List.newBuilder[Int]
for (codeLocation <- coverage.linesNotCovered) {
// handling for Winter 19 SFDC bug:
// https://salesforce.stackexchange.com/questions/237432/bug-blank-locationsnotcovered-returned-from-rest-tooling-runtestssynchronous
val validUncoveredLocations = coverage.linesNotCovered.filter(_.getLine > 0)

for (codeLocation <- validUncoveredLocations) {
locations += codeLocation.getLine
}
val coverageJSON: JsValue = Map("path" -> coverage.filePathInProject, "linesTotalNum" -> coverage.linesTotalNum,
val coverageJSON: JsValue = Map(
"path" -> coverage.filePathInProject,
"linesTotalNum" -> coverage.linesTotalNum,
"linesNotCoveredNum" -> coverage.linesNotCoveredNum,
"linesNotCovered" -> locations.result().toJson ).toJson
"linesNotCovered" -> locations.result().toJson
).toJson
// end result looks like so:
// {"path" : "src/classes/AccountController.cls", "linesNotCovered" : [1, 2, 3, 4, 15, 16,...]}
coverageWriter.println(coverageJSON.compactPrint)
Expand Down

0 comments on commit eb9b1a7

Please sign in to comment.