Vladyslav Nikolaiev
Vladyslav Nikolaiev

Reputation: 2029

PIT Mutation Testing maven plugin skip all private methods

I believe that not all private methods should be tested as independent parts of code. That is why I want to exclude them from pit-reports of PIT testing tool maven plugin. I tried to find a way of doing this, but failed. Some close configuration described here documentation at excludedMethods topic, but it's obviously not the proper way of excluding each private method.

So my question is where a way to exclude all private methods from analyzing by PIT ?

Upvotes: 1

Views: 1993

Answers (1)

henry
henry

Reputation: 6096

You could exclude private methods by implementing a MutationInterceptor

http://pitest.org/quickstart/advanced/

However you probably do not want to do that.

Although private methods should not be tested as independent parts of code, the behaviour they implement (accessed via the public api) should be described by tests that are fast and highly repeatable i.e. unit tests.

So although writing explicit tests for private methods is a bad idea, if your test suite does not kill mutations in your private methods this means you either have a weak test suite or needless code in your private methods.

Upvotes: 6

Related Questions