My 4 yr old has only recently started throwing tantrums. I noticed she has been testing us especially since I began working outside the home for a while. She KNOWS she can get away with this kind of behavior with Daddy. Mommy is not so easy. I just tell her straight out, "You know that Mommy does not allow this behavior, absolutely not" and I put her on time out.
Time outs were losing their effect after too many warnings and not much follow through on my part. Once I realized this I made sure to put her on time out as soon as she needed it. I also made sure that time out was in a place she would consider really boring. She gets no toys or anything at all to fiddle with while she is on time out. This seems to be working.
At the stores, I just have to force myself not to care what others think. I find a quiet spot and put her on time out there. DD can definitely pick up on whether I am embarrassed or not and she works it. I just have to make sure I feel confident in what I am doing.