How to run all modified JUnit test classes?

前端 未结 3 1300
南旧
南旧 2020-12-17 19:28

I have an IntelliJ project, versioned in git.

How can I run all JUnit test classes, that I have modified since my last commit?

3条回答
  •  情歌与酒
    2020-12-17 20:15

    I do not believe there is any 'out of the box' solution to this that you can use. However you could script this in a language of your choice, to find the 'files changed in last commit' you can execute

    git diff --name-only HEAD~
    

    HEAD~ is a reference to the 'penultimate' commit, specifying only one commit reference to the git diff command will automatically compare to HEAD which is the latest commit.

    You could take the output of this and iterate over it, perhaps if your test classes follow a similar naming scheme to your classes to test execute the tests by specifying a pattern for each file?

提交回复
热议问题