I'm trying to understand how to choose the space of test functions when deriving the weak form of a PDE. For my problem specifically, I have one Neumann boundary condition and one Dirichlet boundary condition. Here's the general form in the ODE case,
$$Lu(x)=f(x),\quad x\in (0,Z) \\u'(0)=a,\quad u(Z)=b.$$
I have seen lots of advice (e.g. Test space for weak formulation) saying that the test function should exist in the same space as the weak solution but why is that? What is it about the boundary conditions that tell me what space the solution $u$ and the test solution $v$ should be in?