  In this paper we prove a version of Connes' trace theorem for noncommutative
tori of any dimension~$n\geq 2$. This allows us to recover and improve earlier
versions of this result in dimension $n=2$ and $n=4$ by Fathizadeh-Khalkhali.
We also recover the Connes integration formula for flat noncommutative tori of
McDonald-Sukochev-Zanin. As a further application we prove a curved version of
this integration formula in terms of the Laplace-Beltrami operator defined by
an arbitrary Riemannian metric. For the class of so-called self-compatible
Riemannian metrics (including the conformally flat metrics of Connes-Tretkoff)
this shows that Connes' noncommutative integral allows us to recover the
Riemannian density. This exhibits a neat link between this notion of
noncommutative integral and noncommutative measure theory in the sense of
operator algebras. As an application of these results, we setup a natural
notion of scalar curvature for curved noncommutative tori.
