depends on the type of test- a mouth swab will generally detect use in the past 1-10 days; a urine test will go for 30 days or so; hair test can go back years.... do you know what kind of test you are going to take?
if it is saliva, you should brush your teeth several times a day and rinse with strong mouthwash (listerine), too; for urine test, flush your system by drinking as much water as you can- adding lemon will flush your systme quickly, as lemon juice is a diuretic (makes you pee); for hair, there are shampoos that claim to help, but who knows?
good luck!!