Assuming you are using gradle.
So, for this you need to have a different directory, which is in the same place as your test directory. Name the directory as 'test [BuildVariant]' and have tests for this build option inside this directory.
Suppose you built a debug option, your directory structure will look something like this if you want to test classes that are only in the debug version of the assembly
-debug/java/... -main/java/... -test/java/[your tests] -testDebug/java/[your tests for build variant debug]
source share