I am just running a single unit test
mvn -Dmaven.surefire.debug test -Dtest=org.apache.hadoop.hdfs.server.namenode.TestAddBlock
The tests will automatically pause and await a remote debugger on port 5005. You can then attach to the running tests using Eclipse.
Run > Debug Configarations
If you need to configure a different port, you may pass a more detailed value. For example, the command below will use port 8000 instead of port 5005.
mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" test