Setting the exit code in a trap overrides the exit code that caused the trap to be called. This means if the test failed and called the trap, the test will exit with 0 rather than the failure exit code.