For example, if we consider the Dirichlet energy $\int\frac 12 |\nabla u|^2$ and the solution space as follows:
$$X=\{u\in W^{1,2}(\Omega) \text{ | } u = 0 \text{ on } \partial\Omega \}$$
, then the test function is $C_0^\infty$. My question is that:
Is the test function related to the boundary condition $u = 0 \text{ on } \partial\Omega$?
If $u = g \text{ on } \partial\Omega$, should the test function be changed?