Drug test
A drug test is a technical analysis of a biological specimen – for example urine, hair, blood, sweat, or oral fluid / saliva – to determine the presence or absence of specified parent drugs or their metabolite
Metabolites are the intermediates and products of metabolism. The term metabolite is usually restricted to small molecules. A primary metabolite is directly involved in normal growth, development, and reproduction. Alcohol is an example of a primary metabolite produced in large-scale by industrial...

s. Major uses of drug testing are to detect the presence of performance enhancing steroid
A steroid is a type of organic compound that contains a characteristic arrangement of four cycloalkane rings that are joined to each other. Examples of steroids include the dietary fat cholesterol, the sex hormones estradiol and testosterone, and the anti-inflammatory drug dexamethasone.The core...

s in sport or for drugs prohibited
Prohibition (drugs)
The prohibition of drugs through sumptuary legislation or religious law is a common means of attempting to prevent drug use. Prohibition of drugs has existed at various levels of government or other authority from the Middle Ages to the present....

 by laws, such as cannabis
Cannabis (drug)
Cannabis, also known as marijuana among many other names, refers to any number of preparations of the Cannabis plant intended for use as a psychoactive drug or for medicinal purposes. The English term marijuana comes from the Mexican Spanish word marihuana...

, cocaine
Cocaine is a crystalline tropane alkaloid that is obtained from the leaves of the coca plant. The name comes from "coca" in addition to the alkaloid suffix -ine, forming cocaine. It is a stimulant of the central nervous system, an appetite suppressant, and a topical anesthetic...

 and heroin.
The following chart from LabCorp
Laboratory Corporation of America Holdings , more commonly known as LabCorp, is an S&P 500 company headquartered in Burlington, North Carolina. It operates one of the largest clinical laboratory networks in the world, with a United States network of 36 primary laboratories. Before a merger with...

 gives approximate detection periods for each substance by test type.

The detection windows depend upon multiple factors – drug class,amount and frequency of use, metabolic rate, body mass, age, overall health, and urine pH.