There are currently two ways to test your component in CloudStack.
Unit Tests can be written using Mockito and Spring for your plugin/component and will run as part of the build system. Tests that attempt to access a database or network resource belong to an integrated test. Documentation on writing UnitTests is here
These are tests that will run on a working setup of CloudStack. In other words, the entire management server, hypervisor setup etc is assumed to exist and/or presetup before running these tests. One can think of these as system tests.
1. How to write integrated tests for CloudStack
2. How to include your integrated tests in the build phase