javaintellij-idea

How to select and run only tests that are affected by the change set in Intellij Idea?


I know how to select a latest changeset scope for code format in Intellij Idea. Is there a way to select only those unit tests that are affected by some changeset scope? I.e not only to select the tests affected by the change set as was mentioned there, but select all tests, that are affected by the underlying code, changed within the changeset?


Solution

  • This is not exactly what was asked, but it is a workaround that I have been using lately:

    1. Go to a modified line of code
    2. Find the Call Hierarchy ctrl+option+H of this line of code
    3. Make sure to select the Scope for All the code in the project
    4. Expand All cmd+plus the call hiearchy
    5. Select All cmd+a the entire call hiearchy
    6. Run all selected tests ctrl+shift+R

    This is very usefull when doing TDD and you want to test all the code affected by the change to a single unit, one step at a time.

    Now if this could be implemented as an action to run on the complete changeset, it would indeed be a great feature! 😄