An exercise in Evans PDE is the following.
Let $\Omega$ be connected. A function $u \in H^1(\Omega)$ is a weak solution of Neumann's problem \begin{equation} (*)\qquad\left\{ \begin{array}{rl} -\Delta u = f & \text{in } \Omega \\ \frac{\partial u}{\partial \nu} = 0 & \text{on } \partial \Omega \end{array} \right. \end{equation} if $$ \int_\Omega Du \cdot Dv \; dx = \int_\Omega fv \; dx $$ for all $v \in H^1(\Omega)$. Let $f\in L^2(\Omega)$. Prove $(*)$ has a weak solution if and only if $$ \int_\Omega f \; dx =0. $$
I'm confused with the definition of weak solutions to the Neumann's problem. In my opinion, similar to Dirichlet's problem, the weak solutions are defined as the following. Let $$X(\Omega)=\left\{u\in H^1(\Omega)\mid \int_\Omega udx=0\right\}.$$ (The space $X(\Omega)$ is similar to $H_0^1(\Omega)$ in the Dirichlet's problem.) We say that a function $u\in X(\Omega)$ is a weak solution of $(*)$ if $$\int_\Omega Du \cdot Dv \; dx = \int_\Omega fv \; dx$$ for all $v\in X(\Omega)$. Then we can show that for any $f\in(X(\Omega))^*$, we can find a weak solution $u\in X(\Omega)$ of $(*)$ by Poincare's inequality and Riesz representation theorem. What are the disadvantages of this definition?
Well, suppose $u$ is a smooth solution to your problem (also $f$ smooth), then we know by integration by parts that $$\int_{\Omega}(-\Delta u) v\,dx+\int_{\partial \Omega} \frac{\partial u}{\partial \nu}v\,dx=\int_{\Omega} fv\,dx,$$ for all $v \in C^{\infty}(\overline{\Omega})$ with $\int_{\Omega}v\,dx=0$ (even $v \in X(\Omega)$ but this is not needed). First taking $v \in C_c^{\infty}(\Omega)$, and then general $v$ for the boundary condition, we only find that $u$ solves the equation $$\begin{cases} -\Delta u = f - c & \text{in $\Omega$},\\ \frac{\partial u}{\partial \nu}=0 & \text{on $\partial \Omega$}, \end{cases}$$ for some constant $c \in \mathbb{R}$. In fact, since $$\int_{\Omega} -\Delta u\,dx = \int_{\Omega} -\textrm{div}\nabla u\,dx = -\int_{\partial \Omega} \frac{\partial u}{\partial \nu}\,dx=0, $$ this constant $c$ is exactly $\frac{1}{|\Omega|}\int_{\Omega}f\,dx$. Therefore, even in your setting the assumption $\int_{\Omega} f\,dx=0$ should be imposed to solve the Neumann problem. Since the Neumann problem is invariant under translations by constants, the condition $\int_{\Omega}u\,dx=0$ may be used to make the solution unique, although this is not necessary.