Search code examples
androidunit-testingautomated-testsmockitopresenter

Is there any automated tool available to check if all my Presenter classes have Test classes?


I am looking for any automated tool which can give me a summary of which Presenter classes in my MVP doesn't have a Test classes along with it.

Like I wrote some business logic in my Presenter class but I forgot to write test cases for this class, any automated tool to point this out?


Solution

  • JaCoCo is a great tool to generate tests coverage reports. Anyway, Android plugin only generates the coverage report from instrumented tests. If you want to include the unit testing, it is necessary to create the task manually.

    In the task, it is possible to exclude view classes from the report, for example:

    def fileFilter = [
        'com/sample/**/view/**.*',
        '**/R.class', 
        ...]
    

    Usually, I exclude Android classes (BuildConfig, R, etc) and any other XML file that is out of my test strategy.

    You can find more information here: https://docs.gradle.org/current/userguide/jacoco_plugin.html

    Hope to be helpful, good luck.