most junk yards have the engines pulled already, they were ran before they pull the engine, if it didnt run good they would not re sell it. most yards have the engines all lined up indoors with a tag having all the info for that engine, miles, year, car it came out of and so on. plus they will give you at least a 30 day warranty. they dont want to sell you bad parts/engines, and will back up the parts in the long run, they dont want a bad rep.
ive used a few junk yard motors for cars ive had in the past, and they always run. it may need a tune up and all the regular maintenance stuff done to it, but that should be done anyways.
dont buy from a pull and pray, thats one way to waste your time on a used engine. buy one thats already out of the car, its been tested.