This question already has an answer here:
Trying to identify this movie I saw a long time ago. I watched it in the 90s but it was probably from the 80s and not terribly well done either. Probably B-Movie levels.
I can only remember a few points: There's a ship in deep space and there's a crew of a maybe ~6-8 characters. Stuff happens where characters are slowly killed off. The only one I remember was a VR machine they use for relaxation. One guy uses it for VR sex but gets killed during the session. Everyone is tense about the mysterious deaths. Something happens (I think the life support breaks?) and this causes a lot of strife among the crew members who slowly kill each other off. Finally there's like 2 people left after everyone else is dead and they are close to death and they just decide to space themselves so they open the hatch and find out they were on earth (or some planet anyway) all along. Iirc, the planet looked like a post-apocalyptic one with ruined cities. It was a simulation to test them or something like that.
NB: It's not 'Alien Intruder' from '93, that one has the VR aspect, but the film I'm thinking about had the VR as only a minor thing.