In my opinion, it really depends on the the size of your file and the complexity of your procedure. For me, if it's one simple procedure, I guess having it in the file works, and I'd do it the way @shirleyquirk does. But if it's multiple procedures or a complex one, I'd probably separate it out.
For projects, I'd have all the tests in a separate directory. I personally follow the nimble directory layout: * src/ * bin/ * tests/ Hope this gives you some insight.
