Testing Tip: Run Test Method from Abstract Test Class

Sometimes you have an abstract test class with test methods where the inheritors set up different environment. As it is impossible to run an abstract class you had to enumerate inheritors manually, choose corresponding methods and run these methods one by one.

Now (since IntelliJ IDEA 11.1) it is possible to run tests right from the abstract base class and simply choose inheritors from the popup.

This works for JUnit and for TestNG tests.

This entry was posted in New Features and tagged , , . Bookmark the permalink.

5 Responses to Testing Tip: Run Test Method from Abstract Test Class

  1. Jan Jordanow says:

    is there some configuration? cause this ‘popup with inheritors ‘ doesn’t pop up each time. Is it a bug or feature?

  2. Anna Kozlova says:

    Hi Jan,

    Sounds more like a bug. Could you please file more details? When it doesn’t appear? Thanks

  3. Isaac Aggrey says:

    The popup doesn’t seem to appear if you have a run configuration for the abstract base class instead of the concrete class. In order to reproduce, all you have to do is change the Class in the run configuration for the test to the abstract base class*, but once I deleted that configuration it shows the popup again.

    *which of course won’t work when you run the test due to it failing to instantiate, but you may still end up in this state if you don’t know what you’re doing or have an old configuration after refactoring

  4. Arun Kottayil says:

    @Isaac Aggrey, Thanks , saved my day.

  5. Blair Stewart says:

    @Isaac Aggrey, Thank you. Having the same problem in Intellij 2018.1.6, you saved the say again.

Leave a Reply

Your email address will not be published. Required fields are marked *