mardi 27 juin 2017

Verify / Ensure test code is only called in tests, not in production code

In one of our projects at work, we have started using Guava's VisibleForTesting to annotate "helper" methods that must only be used for testing (e.g. a Setter to allow for service mocks to be "injected"). In production, the application should use Spring's Autowired to "get" its services.

Is there a way to check if code annotated with VisibleForTesting is only called in test code (static analysis, not if someone tries funny stuff via reflection)?

Aucun commentaire:

Enregistrer un commentaire