This is completely normal for development work, so its like asking, "what do you do when everything is normal." In your case you have a tricky bug, so tests are the best bet. When you are making the test, the cause of the bug will probably become apparent before you finish writing the code.