Let $\omega$ be a closed differential form over the torus $T$. Suppose $$\int_T \omega \neq 0.$$ Why does it follow that $\omega$ represents a nonzero cohomology class on $T$? I assume this somehow follows from Stokes' Theorem, and this is what I have thought of so far.
Assume that $\omega$ does not represent a nonzero cohomology class of $T$. Then it must be exact, so write it as $\omega = d\beta$. Then $$\int_{\partial T} \beta = \int_T d\beta = \int_T\omega \neq 0.$$ But this is a contradiction, as $\partial T = \emptyset$ which implies $$ \int_{\partial T} \beta = 0.$$Hence $\omega$ must represent a nonzero cohomology class.
Is this correct? If so, I assume this statement does not hold in general for manifolds with nonzero boundary?
Recall the definition $$ H^{2}_{\text{de Rham}}(T;\mathbf{R}) \cong \frac{\{ \text{closed $2$-forms} \}}{\{ \text{exact $2$-forms} \}}. $$ If $\omega$ is closed (as all $2$-forms on a $2$-manifold are), then $\omega$ determines a (de Rham) cohomology class. This cohomology class is trivial precisely when $\omega$ is exact. By Stokes's theorem, $\omega = d\eta$ would imply $$ \int_{T} \omega = \int_{\partial T} \eta = 0. $$ In sum, $$ \text{$\omega$ determines the trivial cohomology class} \iff \text{$\omega$ is exact} \implies \int_{T} \omega = 0. $$ Hence, the hypothesis that $\omega$ has nonzero integral immediately implies that $\omega$ determines a nontrivial cohomology class.
We used above the fact that $\partial T$ is empty. Indeed, the statement does not generalize to surfaces with boundary. Here is a counterexample.
Consider the cylinder $S^{1} \times [0,1]$ with the $2$-form $\omega = d\theta \wedge dt$. The Künneth formula reveals that all $2$-forms on $S^{1} \times [0,1]$ are exact. Indeed, $$ d(-td\theta) = -dt \wedge d\theta = d\theta \wedge dt = \omega. $$ We can now use Stokes's theorem to evaluate the integral. $$ \int_{S^{1} \times [0,1]} d\theta \wedge dt = \int_{\partial(S^{1} \times [0,1])} -td\theta = -2\pi. $$