A cocaine test can happen when you get a new job or have to have one to continue employment. This is one drug that they look for when they take a sample from you, with urine being the most common way of collecting one to test.
They do not test for cocaine as such, but for benzoylecgonine. This is cocaine that has been metabolized in the system and the remains for which they look for to fail you in the test. It does not matter if it is cocaine or crack, this is what appears.
Cocaine drug testing can give you a positive, even if you have no done the substance for several days. This is because the concentrates in the urine can change throughout the day, and like a pregnancy test, can be higher in the first urine of the day. This is not always true, however, since the length of time you have used the substance can also come into play with the amount that you have.
Drinking a lot of water can help dilute the urine and cause the cocaine to appear in your system light enough to be able to pass the test. Be aware, that you may be called in for additional testing since some labs get suspicious of this activity. There are also kits that offer nutrition, diuretics and guides that you can use to lower the amount in your sample as well.
Most of the time, a cocaine test will show the during in the system for 10 days or more for an average user. Generally, it will be out of your system in about a month. Your results can vary, and it can be sooner or later. The best way to pass any of the testing is to not use illegal substances, but if you do, there are things that you can do to help pass them.