Skip to content

Realtime integration in the HTML reporter #1429

@hugo-vrijswijk

Description

@hugo-vrijswijk

Realtime Reporting

Add support for realtime reporting in the HTML reporter in Stryker4s.

See https://stryker-mutator.io/blog/announcing-realtime-reporting-for-stryker/

Implementation

Since Stryker4s uses Cats-Effect and related libraries, a good choice for a web server is http4s. It works great for streaming, which is what we need for this feature (server-sent events). The reporter could simply return a stream of initial state, keep listening for new reporter updates and stream those, and end the stream when the reporter is finished. Something like a topic might be useful.

Encoding of responses can be done with http4s-circe.

Ideally, we'd keep some in-memory state of all tested/pending mutants, and send this state to the client when it connects. This way, we can prevent missing data in the browser when a client connects after the mutation testing is done or refreshes the page.

  1. When all mutants have been created, write the report file to disk so it can be opened and start the server.
  2. After opening the HTML file, the report will open an endpoint with the text/event-stream header.
  3. When a mutant is tested, send an event to the browser. This event should at least contain a mutant id and the new status.
    a. It might also be nice to put these mutants in a list, and output them when a client is connected. This could be used to prevent missing mutant data in the browser.
  4. When mutation testing is done, send a different event so that the report knows it won't receive any new updates.
  5. Finally, write the complete version to disk (as we currently do).

Question(s)

  1. Should this be a separate reporter? If we're already writing to disk, it could stay in the 'html' reporter. But starting a server feels like a different responsibility.
  2. Should this functionality be behind a flag, like in Stryker.NET (-o, opens the browser automatically)? Or a config option (one for the port might be useful)
  3. For updating state, we'd have to constantly update the report object. A clean way to do a 'deep' update is through lenses (like Monocle). This would fit in the mutation-testing-metrics package. I think their most recent version dropped 2.12 support, which we still use. It would be nice to have a version that works with Scala 2.12, 2.13 and 3. If that doesn't exist, perhaps only supporting 2.12-2.13 would be enough for our use case (until we later stop building on 2.12).

Metadata

Metadata

Assignees

Labels

hacktoberfestGreat issues to pick up for Hacktoberfest

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions