The engine still runs well often when a car is totalized from a crash. However, not ever. Especially if the vehicle was destroyed at the front or if the hood was shot. You can think about the engine’s condition in two ways. You should buy and mount the engine and see if it works. Or you might buy a proven engine. Of instance, the second approach is simpler.
Two key research techniques are available. The first one is a moving test. A qualified mechanic can do it and checks the engine on a stand or even connected to the car can start the engine.
A compression test is the second process. This is used if the car doesn’t start anymore and you can say a lot about the engine state. Ask about checking, particularly if you buy one without a promise before you buy an engine.