stryker4s icon indicating copy to clipboard operation
stryker4s copied to clipboard

Support full new schema

Open hugo-vrijswijk opened this issue 4 years ago • 2 comments

The latest mutation-testing-report-schema release added new properties to the schema. We should fill as many of them as we can:

  • [x] testFiles can be filled per fullyQualifiedName of a test suite
  • [x] coveredBy in a mutant
  • [x] killedBy in a mutant
  • [x] duration in a mutant
  • [x] testsCompleted in a mutant
  • [ ] performance
  • [x] framework, we can fill dependencies with at least the sbt and stryker4s version. Perhaps the test framework too
    • [ ] Dependencies is not filled at the moment, but other framework info is
  • [x] system, we can easily fill ci, os and cpu
  • [x] config

hugo-vrijswijk avatar Dec 23 '20 21:12 hugo-vrijswijk

https://raw.githubusercontent.com/stryker-mutator/mutation-testing-elements/master/packages/mutation-testing-report-schema/src/mutation-testing-report-schema.json

It seems like the mutation score per file is NOT included in the schema but, I presume, calculated on-the-fly by the UI component?

That's problematic because I want to log the score to an external database/chart after stryker4s is finished in CI. Isn't it also duplicating the score calculation in both stryker4s.report.ConsoleReporter and the web UI (and the Dashboard?). 🤔

Any ideas of how I can get the score out into my CI runner would be helpful - short of rendering the UI component in a virtual DOM...

cbrunnkvist avatar Mar 25 '21 12:03 cbrunnkvist

@cbrunnkvist Yes, to prevent duplicate data in the JSON, the mutation score is calculated on the fly.

Rendering the html report definitely doesn't seem ideal, haha. You might want to look at the mutation-testing-elements repo which has a library for Scala and NodeJS to calculate metrics based on a report in a standard way. That code is used by StrykerJS, Stryker4s, the html report and the dashboard to calculate the score (and a couple of other things).

If there's something missing in the metrics, or it doesn't fit your use-case, let me know! We're happy to support more use-cases!

For example, to get the score in Ammonite:

@ import $ivy.`io.stryker-mutator::mutation-testing-metrics-circe:latest.release`, mutationtesting._, mutationtesting.circe._, io.circe._, io.circe.parser._

@ val report = decode[MutationTestResult[JsonObject]](scala.io.Source.fromFile("./report.json").mkString).right.get
@ val metrics = Metrics.calculateMetrics(report)
@ metrics.mutationScore
res15: Double = 70.24070021881839

hugo-vrijswijk avatar Mar 25 '21 13:03 hugo-vrijswijk