Cats use elimination as a way of marking territory. While they are typically clean creatures, stress caused by a change in environment from a visiting relative, a new cat, or a different rug in the house, can cause them to feel the need to mark territory by defecating in odd places. Another reason for using the bathtub instead of the litter box could be that a previous owner either had the litter box in the tub, or used the tub as the litter box. Whatever the reason, there are simple steps to break your cat of pooping in the bathtub.
Close the bathroom door. If you keep the litter box in the bathroom with the tub the cat is pooping in, relocate the box to an easily accessible but out-of-the-way spot.
Put some water in the tub. Even just an inch or so of water will discourage most cats from using the tub as a litter box.
Retrain the cat to use the litter box by placing the cat in a small room with food and water and a bed at one end, and the litter box at the other end. Keep the box spotless, and limit the cat's freedom until it is regularly using the box again.