How to run all modified JUnit test classes?

I have an IntelliJ project versioned in git.

How can I run all of the JUnit test classes that I have changed since the last commit?

+7
source share
3 answers

The project tool window has a predefined area Modified files , which you can use to view all modified vcs files. From there, select all the JUnit classes and in the context menu, create the JUnit Run / Debug Configuration, which will populate the class template for automatic launch.

+7
source

I do not believe that there is such an out of the box solution that you can use. However, you could have the script do this in your language of choice to find the β€œfiles modified in the last commit” that you can execute

git diff --name-only HEAD~ 

HEAD~ is a reference to the "penultimate" commit, indicating only one commit reference to the git diff , which is automatically compared to HEAD , which is the last commit.

You can take the result of this and iterate over it, perhaps if your test classes follow the same naming scheme for your classes to test the execution of tests by specifying a template for each file?

0
source

This library seems to provide similar functionality: https://github.com/rpau/junit4git

This is a JUnit extension that ignores those tests that are not related to your latest changes in your Git repository.

0
source

Source: https://habr.com/ru/post/1268135/


All Articles