You have asked a heavy question for which you seem to already have a partial answer. You said yourself that your refusal to lose weight is your way of testing to see whether your boyfriends will love you even if you don't lose weight. Your theory makes a lot of sense. Now the question is why do you need to conduct such a test.
It sounds like you are looking for unconditional love--that is you are looking for your man to say that he loves you no matter what. Your hunger for unconditional love from a boyfriend tells us the exact nature of your unfinished childhood business. Let me explain. In order for the young child's psyche to develop normally, he/she needs to feel that mom and dad love him/her unconditionally. If that love isn't provided, the person is left with a hole inside the self, a craving for unconditional love.
Cut to adulthood and that person will look for lovers who can fill the hole, no pun intended! This explains why you are looking for someone to give you unconditional love that you never received as a kid. The problem is that adult relationships can't replicate the parent/child bond. No boyfriend, husband, girlfriend or wife can be expected to provide unconditional love to his/her partner. Adult love comes with strings attached.
You are going to need to see that what you lacked in childhood can't be replaced by a boyfriend. If you continue to test your boyfriends, you are going to lead a miserable life; not only won't you receive the unconditional love you craved since childhood, you are also going to set yourself up to experience trauma after trauma, when men leave you and you feel more and more unloved, just as you did when you were young.
The only way out of this terrible mess is for you to begin therapy. The therapeutic relationship can offer you unconditional love. Little by little the void will be filled inside yourself and you won't feel the need to continue looking for 'unconditional love in all the wrong places.'