There are multiple ways to do this in Exchange 2010, the best of which would depend on your setup and details you haven't shared.
Based on the assumption you have relatively few addresses in the test environment, I'd use account-level delivery restrictions to accomplish this. Only give addresses in your "test" environment permission to send to the specific users they need to send mail to, or to email addresses in your domain.
If you have a prohibitively large number of test email addresses, well you should probably do something about that anyway, but you could also use send and receive connectors to make sure emails going outside of your domain don't get relayed. That's (IMHO) more of a pain that just using the delivery restriction options on the accounts that need restricted, but it's another way to go, if you need to.