I have a feature branch with plenty of commits.
ant rebuild test
While you are on branch
git rebase --interactive --exec "ant rebuild test" C
This will cause git to start again on commit C, replay your work on top and it will run your tests after each commit it applies during replay phase.
Hopefully your ant task will have a non-zero exit code if your tests fail. In this case git will stop as soon as the tests fail. You are immediately in the right position to amend you commit so that the tests will be happy again. After you have amended just execute
git rebase --continue as usual and git will continue to check all you commits.