Run testng test in Git pre-commit hook
mvn clean test -Dtest="MyTestName"
One Solution collect form web for “Run testng test in Git pre-commit hook”
pre-commit hook returns non-zero, then the commit is aborted before it even starts. In a bash script, by default the return value of the last command run is the return value of the script. By my understanding
mvn clean test should return non-zero on failure, so your script should be as simple as:
#!/bin/sh mvn clean test -Dtest="MyTestName"
Then just name it
pre-commit in your
.git/hooks/ directory in your repo and run
chmod ug+x on it to make sure it can be executed.