[warning -- I dictated this to my phone so beware of homonyms.]
The following is probably both obvious and overly simplistic, but (putting aside emotional development for the moment) the primary purpose of instruction should be to increase students' mastery of the material (both knowledge and process based) while the primary purpose of tests is to measure that mastery. Those definitions are ridiculously broad but they'll serve for the moment, as will the rule of thumb that any instructional practice that doesn't improve mastery of the material or validity of the test should be viewed with suspicion.
I should also note before going any further that it has been many years since I got my teaching certificate and I have long since forgotten what little terminology I once knew. For the next few paragraphs I'll just be coining my own.
Teaching to the test – inclusive vs. exclusive
Inclusive teaching to the test – – making sure to cover everything students will be tested on – – is always defensible and is generally a very good idea.
Exclusive teaching to the test – – leaving out material you would otherwise cover because it is not going to be tested over – – is much more of a gray area. Obviously, teachers have to prioritize, but this should, at the very least, give one pause. In most cases, the test should include only a proper subset of the material covered.
Teaching to the meta-test -- prepping kids on the non-content aspects of the test -- gets even more gray. On a very high level it is certainly justifiable. You wouldn't want to have kids encountering strange formats and confusing instructions for the first time when they sit down to take a major test. On the other hand, this is an example of instruction that doesn't improve mastery of the material. If done for certain groups of students and not others, it runs creating an unfair advantage and thus undermining the validity of the test, which leads directly to...
Changing the conditions of the test
In order to get the most valid results, it would be best if all kids took all tests under optimal conditions -- motivated, well rested, comfortable, relaxed and free from distraction. We would always like to be sure that a low score represented a low mastery rather than a poor night's sleep. If, however, we can't be universally optimal, it is important that the suboptimal be distributed as uniformly as possible.
Teaching the actual test
Everything we've covered up to this point has ranged from OK to borderline, but ethical and even legal lines are quickly crossed when specifics of the test start making it into the prep materials available to only certain students. When individual teachers and administrators do this, they lose their jobs. When the companies that make the tests do it by selling "aligned" texts and prep materials, their stock goes up.
If you've been following the no-excuses discussion, lots of these concepts should sound familiar.