Unless there is obvious or visible damage or dysfunction, minor issues can be quite hard to determine. You can severely compromise the front element of a lens and it will still mostly work. However a scratch on a rear element will be much more noticeable. But you can have dust in a lens or camera body with little or no noticeable effects.
If you have the ability to see images produced by a lens or camera body you can look for some things such as dark spots, which may indicate dust or dirt on the lens, or banding which may indicate some deeper malfunction. For a lens, the most common problems show up as poor focus, or uneven focus across an image.
If you are asking before you buy, just make sure you have some reasonable amount of trust in who you are purchasing from. In general, photography equipment holds up very well, if taken reasoanble care of.