Deploying and testing solution to SharePoint online is different from SharePoint on premises environment. For SharePoint online we can only create sandbox solutions which are site collection scoped.
There are two options for SharePoint online testing environment
1. Create new site collection
Our goal here is to provide separate environment for testing solutions. SharePoint sandboxed solutions are site collection scoped, so we can create new site collection for testing custom solution before deploying it to production site collection.
This option will not work if your code required making changes on tenant level. E.g. if you are making use of BCS, this might be not a good option.
2. New Office 365 account (tenant)
If you want to make sure that there should be a separate environment for testing in cloud, then consider this option. You can buy a test environment license for few users, or a 30 days trial version can be used for testing purpose.