let have a random variable X which follows a normal distribution of mean $\mu$ and variance $\sigma$. we want to carry out the following hypothesis test:
$H_0: \mu=\mu_0$ against $H_1: \mu\neq\mu_0$
where $\mu_0$ is a constant.
How to show that under the hypothesis $H_0$ we have $\frac{\bar{X}-\mu_0}{S/\sqrt{n-1}}$ follows $t_{n-1}$.
where $\bar{X}$ and $S$ are respectively the sample mean and the sample standard deviation, $t_{n-1}$ is student's law of the degree of freedom $n-1$.
Note that $$ \frac{\bar{X}-\mu_0}{S/\sqrt{n}}=\left(\sqrt{n}\frac{\bar{X}-\mu_0}{\sigma}\right)\bigg/\sqrt{\frac{(n-1)S^2}{\sigma^2}\bigg/(n-1)}\sim t_{n-1} $$ since it is in the form $$ Z\bigg/\sqrt{W/(n-1)} $$ where $Z\sim N(0,1)$, $W\sim \chi^2_{n-1}$ and $Z\perp W$.