The answer below is for the first version of the question:
I'd really like to receive the messages from the integrand. How can I stop
NIntegratefrom suppressing the messages?
There are several reasons for this behavior. Generally speaking, NIntegrate pre-evaluates and localizes the integrands in order to facilitate different symbolic pre-processing and numerics algorithms.
If we redefine the integrand with Piecewise we will get the message once, when PiecewiseNIntegrate does the preprocessing:
In[142]:= ClearAll[Test, test] test[x_] := Piecewise[{{Message[Test::message]; x^2, 1 < x < 2}}, x]; NIntegrate[test[x], {x, 0, 3}] During evaluation of In[142]:= Test::message: -- Message text not found -- Out[144]= 5.33333 Further, we can prevent the symbolic processing with _?NumericQ and use Print or Echo. (Note that the integral converges too slowly.)
ClearAll[Test, test] test[x_?NumericQ] := If[1 < x < 2, (Echo[Row[{Test::message, " : ", x}]]; x^2), x]; NIntegrate[test[x], {x, 0, 3}, PrecisionGoal -> 2] (* Test::message : 1.08055 Test::message : 1.5 Test::message : 1.91945 ... 5.34841 *) I am not sure what kind of testing you want to do. You might consider using EvaluationMonitor or IntegrationMonitor instead.