At Least Verify Code Execution If Lacking Unit Tests

Here’s a trick if you don’t have time to ensure good unit tests before pushing code.

Ensuring Code Execution of All Branches Changed

Add print statements with numbers over all the conditional branches of what you are changing.

Manually exercise the code and see that every number printed at least once.

Only then, do you delete the print statements that you’ve seen.

Bottom line is that if you push code that was not run at least ONCE that is grossly wrong…well, that’s embarrassing. We’ve all been there.

Pro-Tip: There’s a RubyMine Find In Path (cmd-shift-f) scope for searching for either console.log or puts in your changed files.

Ensuring Error Handlers Work

This is a nice way to verify that error handlers were also executed. Change a method call to throw, return nil, etc. and check that catching code does the right thing in terms of logging, etc.

Proofread Your Pull Request on Github

  1. I find that just the change of perspective when looking at code in the PR allows me to spot more errors.
  2. You can make comments on your own code that will help the reviewer. These are comments that don’t justify being in the source code.
  3. Check that you didn’t leave in any console.log or puts statements, and that all debugging comments are removed