[guided]The natural [test function](/page/Test%20Function) is $u(\tau)$ itself, because this is the choice that produces both the time derivative of the energy and the coercive gradient term. The only point requiring care is that $u$ is not assumed classically differentiable in time. The Lions-Magenes energy identity for the Gelfand triple $H^1_0(U)\subset L^2(U)\subset H^{-1}(U)$ applies because $u\in L^2(0,T;H^1_0(U))$ and $\partial_t u\in L^2(0,T;H^{-1}(U))$. It gives a representative $u\in C([0,T];L^2(U))$ and, for every $t\in[0,T]$,
\begin{align*}
\frac{1}{2}\|u(t)\|_{L^2(U)}^2-\frac{1}{2}\|u_0\|_{L^2(U)}^2=\int_0^t \partial_t u(\tau)(u(\tau))\,d\mathcal{L}^1(\tau).
\end{align*}
Now we use the weak formulation in a way that permits a time-dependent test function. For every map $w:(0,T)\to H^1_0(U)$ with $w\in L^2(0,T;H^1_0(U))$, the integrated weak formulation states
\begin{align*}
\int_0^t \partial_t u(\tau)(w(\tau))\,d\mathcal{L}^1(\tau)+\int_0^t\int_U A(x,\tau)\nabla u(x,\tau)\cdot\nabla w(x,\tau)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(\tau)=\int_0^t f(\tau)(w(\tau))\,d\mathcal{L}^1(\tau).
\end{align*}
Why is this stronger-looking formulation available? Starting from the pointwise-in-time weak formulation, we first multiply by indicators of measurable time sets and fixed test functions $v_j\in H^1_0(U)$, then add finitely many such identities. This proves the integrated identity for simple maps $w(\tau)=\sum_{j=1}^m \mathbb{1}_{E_j}(\tau)v_j$. Such simple maps are dense in $L^2(0,T;H^1_0(U))$, and the three terms are continuous with respect to this norm: the time-derivative term by $\partial_t u\in L^2(0,T;H^{-1}(U))$, the elliptic term by boundedness of $A$, and the forcing term by $f\in L^2(0,T;H^{-1}(U))$. Therefore the identity holds for $w=u$, since $u\in L^2(0,T;H^1_0(U))$. Replacing the time-derivative term by the Lions-Magenes identity gives the energy balance
\begin{align*}
\frac{1}{2}\|u(t)\|_{L^2(U)}^2-\frac{1}{2}\|u_0\|_{L^2(U)}^2+\int_0^t\int_U A(x,\tau)\nabla u(x,\tau)\cdot\nabla u(x,\tau)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(\tau)=\int_0^t f(\tau)(u(\tau))\,d\mathcal{L}^1(\tau).
\end{align*}
This is the exact weak analogue of multiplying a classical parabolic equation by $u$ and integrating over space and time.[/guided]