Is it possible to obtain a bachelor's degree by passing some test to prove equivalent knowledge rather than attending a university?
In general, no, it is not possible to get a bachelor's degree from an accredited university in the US purely through examinations.

It is possible to get course credits that can partially satisfy graduation requirements through tests such as those administered as part of the Advanced Placement or International Baccalaureate programs. However, these normally tend to be restricted to satisfying general education requirements, rather than the in-depth major requirements.