mardi 15 novembre 2016

Coverage testing os.Exit scenarios in Go with Goveralls

This question: How to test os.exit scenarios in Go (and the highest voted answer therein) sets out how to test os.Exit() scenarios within go. As os.Exit() cannot easily be intercepted, the method used is to reinvoke the binary and check the exit value. This method is described at slide 23 on this presentation by Andrew Gerrand (one of the core members of the Go team).

However, this method appears to suffer certain limitations:

  1. Coverage testing with goveralls / coveralls.io does not work - see for instance the example here (the same code in a package) which produces the coverage test here, i.e. it does not record the test functions being run.

  2. Rerunning the test binary appears fragile.

Is there a way around this? Particularly the first point.

Aucun commentaire:

Enregistrer un commentaire