Like with all things, it needs to be a judgement call. You need to gauge your chance for success.
Desired outcome: You revive the teammate and undo a potential ticket loss
Undesired outcome: You die attempting to revive and both of you are ticket losses
Acceptable outcome: You die but get the revive off just before doing so, and the teammate kills or escapes.
So you have to gauge what your chances are. You can't make a blanket statement of "never res while there are enemy around" because there are times when ressing is the smart thing. One time I turned a corner to see 3 dead teammates who fell to the hand of two enemies hiding behind a piece of blockade. There was no way I could attack the enemies myself, it was 2on1 and they had entrenchments. Considering they had just fired their guns and it was logical to assume they were probably reloading, I took the risk, dashed to the first teammate, and flopped on him just as they started firing on me. Revive worked, I got up and hid quickly behind a corner, and the teammate I just revived started retaliating. Teammate distracted the two, and I ran out again and revived the other two teammates. Enemy killed the first teammate, but two new revives killed them, and I re-revived the original teammate.
Risk was high, but so was the reward, nothing ventured, nothing gained.
Of course if it's a hopeless situation, like an APC sitting right on top of you, there is no point, as you are always going to get the undesired outcome which is double ticket loss. But in general, if you are a grunt complaining about actually receiving medical aid, you need to give your head a shake. It's so rare that there is even a mediocre medic, let alone a good one helping the team that you unfortunately have to take what you can get.