What could it be if engine doesn't want to turn over but lights come on? on 2002 Saturn SL1

When pulling out car shut off and acts like it wants to shut off while driving or slowing down. Then didn't want to start. Waited awhile then started and drove like nothing ever happened. What could it be?

Asked by for the 2002 Saturn SL1
have your alternator tested.