Plugin development - callback for finish of tests

I want to create the following script:
- Run junit tests
- Than, if tests are not failed, I will commit my changes

I use com.intellij.execution.ExecutionManager#restartRunProfile for run of tests.
It's necessary to detect when tests are finished for my following checks. Is there a callback/ listener to subscribe to for that?