Goblin Test Pilot‘s ability says that it deals damage to “target creature or player chosen at random”. A target creature, while activating this ability, can only be chosen if it can be legally targeted by the Test Pilot. An opponent’s creature (or the opponent) with hexproof or any creature with protection from red or from creatures, for example, will not be a part of this “random selection” because it’s an invalid target to begin with.
Note that since Goblin Test Pilot says “…target […] chosen at random”, the random target is chosen when putting the ability on the stack. Players will know what the target is upon activating the ability, and can respond accordingly before the ability resolves.
Today’s Rules Tip written by Eddie Cheung