In general contractions are avoided in formal writing. But this is a matter of style, not a rule. As for the cases you list in the question:
(1) Academic literature,
Contractions are generally avoided in such works.
(2) novels
This varies widely. Some authors use contractions freely in expository and narrative text, others do not.
(3) news reports
Newspapers have traditionally valued brevity highly, because of the limited physical space in a printed newspaper, and used contractions freely. Online news stories are not constrained by physical space, but they want readers to be able to read their stories quickly, and some value an air of informality. Some will use contractions, others will not.
(4) Language tests
These may well want to test use of contractions. Beyond that, I suspect they will tend to avoid contractions, but I am not sure.
Other forms which tend to avoid contractions:
Laws and regulations; legal contracts; technical writing (although this varies a good deal); serious but non-academic non-fiction, for example serious but popular history or biography.
In all these cases this is a matter of style, and not all writers will avoid contractions. In general, contractions are becoming more acceptable than they were, say, fifty years ago, when I was first learning English.
Using contractions inconsistently, say using "don't" in one paragraph, but using "do not" in a similar construction in the next paragraph, is usually poor style, unless it is begin done for some specific purpose by the author. Some readers will be bothered by this, others will not notice or not care. Consistently using some contractions but not others is not inconsistent in this sense, and should not bother most readers. Again this is a matter of style.
Sometimes an author will intentionally vary the style within a work, particularly a long work, having some sections in a more chatty and informal style, and others in a more formal style. When this is not overdone, it can be effective.