There is actually a shunit2, an xUnit based unit test framework for Bourne based shell scripts. I haven’t used it myself, but it might be worth checking out.
Similar questions have been asked before:
- Unit Testing for Shell Scripts
- Test Anything Protocol in Shell Scripts