Paternity Test

Hi! I recently found out I’m pregnant but not by my husband because we were planning on divorcing and I moved on. I planned to get pregnant by my boyfriend and on the first try I ended up pregnant. I didn’t think it would happen. I decided due to potential issues I saw with my boyfriend that I no longer wanted to be with him and now he is saying he is unsure the baby is his. Would you do a paternity test prior to the birth and then just tell him to kick rocks since he acts like the baby now isn’t his?