Do colleges want/require to take the AP class or just the AP test?

There are a few classes that my school does not offer, and a few classes I might take if I had more class periods in the day.

The majority (I am assuming) of an AP course material can be found online.

If I take an AP test and get a passing score for what a certain college is looking for, might they not give credit for the test if I did not take the class?

Thank-you!

See the thread about self-studying aps, it’s great. Get a prep book and try to find youtube videos or khan academy on the subject. I also recommend schmoop.com

With that, if I take the AP test will colleges not take the test seriously if I did not take the corresponding AP class?