How sampling distribution affects the result of hypothesis t-test I am aware that t-test can be used for sample that is not strictly normally distributed according central limit theorem. 
My confusion is that, since the formula of t-test is fix, we can just calculate the parameters (mean and standard error) and use them in t-test. Why do we have to care the sampling distribution? In another word, how sampling distribution affects the result of hypothesis t-test?
 A: A correct t test with normal data. Suppose we have a sample of size $n = 10$ from a population with
unknown mean $\mu$ and we want to test $H_0: \mu = 100$ against
$H_a: \mu > 100.$ If the population mean is actually $\mu_0 = 100$
and data are normal then the t statistic $T = \frac{\bar X - \mu_0}{S/\sqrt{n}}$
has Student's t distribution with $n - 1 = 9$ degrees of freedom.
Then, rejecting for $T \ge  1.933,$ we will have a test at the 5% level.
That is, when $H_0$ is true, we will (falsely) reject with probability 5%.
For the case of data from $\mathsf{Norm}(\mu = 100,\, \sigma=10)$ we use R to simulate
a million samples of size $n = 10,$ and find the $T$-statistic for each.
As it should be, in just about 5% of the million t tests, we reject $H_0.$
set.seed(424)
n = 10;  mu.0 = 100
m = 10^6;  t = numeric(m)
for(i in 1:m) {
  x = rnorm(n, mu.0, 10)
  a = mean(x); s = sd(x)
  t[i] = (a-mu.0)*sqrt(n)/s }
c = qt(.95, n-1)
mean(t >= c)
[1] 0.050305

Here is a histogram of simulated values of $T$ (omitting a few very extreme
values for a better graph), along with density curve of Student's t distribution with $9$ degrees of freedom. The vertical dotted line is
at the critical value $c = 1.933.$ The probability to the right of this line is 5%.

Incorrect use of the t test with exponential data. However, if I try to use the same "t test" with samples from an exponential distribution with mean $\mu = 100,$ the $T$-statistic does not have 
Student's t distribution. For the exponential distribution with $\mu = 100,$
what was intended to be a test at the 5% level has turned into a test at 
about the 1.4% level. 
[The t statistic is well known for its 'robustness' against mildly non-normal data, but exponential data is highly right-skewed with many extreme outliers in the right tail. Especially with relatively small samples, trying to use a t test for exponential
data is 'pushing a good thing too far'.]
set.seed(425)
n = 10; mu.0 = 100
m = 10^6; t = numeric(m)
for(i in 1:m) {
  x = rexp(n, 1/mu.0)
  a = mean(x); s = sd(x)
  t[i] = (a-mu.0)*sqrt(n)/s }
c = qt(.95, n-1)
mean(t >= c)
[1] 0.013939


Correct gamma test for exponential data. A correct test of $H_0: \mu = 100$ against $H_a: \mu > 100$ for samples
of size $n = 10$ from an exponential distribution, is based on the
statistic $V = \bar X/\mu_0,$ which has distribution $\mathsf{Gamma}(\text{shape}=10, \text{rate}=10)$ when $H_0$ is true. Because $\mu$ is in the denominator, we reject for small values of $V.$
Here is a simulation. Notice that the test statistic fits the null distribution and that the actual significance level is 5%.
set.seed(2019)
m = 10^6; v = numeric(m)
n = 10;  mu.0 = 100
for(i in 1:m) {
  x = rexp(n, 1/mu.0)  
  v[i] = mean(x)/mu.0 }
c = qgamma(.05, n, n)
mean(v <= c)
[1] 0.050183


