Trace of non-negative self-adjoint integral operator 
Suppose that $K:L^2([0,1],\mathbb C)\to L^2([0,1],\mathbb C)$ is a bounded linear integral operator given by
  $$
Kf(x)=\int_0^1k(x,y)f(y)dy
$$
  for each $f\in L^2([0,1],\mathbb C)$ and $x\in[0,1]$. Let us further assume that $K$ is non-negative self-adjoint and trace class. Can we conclude that $\operatorname{Tr}K=\int_0^1k(x,x)dx$?

The trace of a non-negative self-adjoint operator is given by (see here)
$$
\operatorname{Tr} K=\sum_i\langle Ke_i,e_i\rangle,
$$
where $\{e_i\}$ is an orthonormal base of $L^2([0,1],\mathbb C)$. Hence, we have that
$$
\operatorname{Tr} K=\sum_i\int_0^1\biggl[\int_0^1 k(x,y)e_i(y)dy\biggr]\overline{e_i(x)}dx=\sum_i\int_0^1\int_0^1 k(x,y)e_i(y)\overline{e_i(x)}dydx.
$$
However, I am not sure if it is possible to proceed without further assumptions on the kernel $k$.
If we assume that $k(x,y)=\varphi(x)\overline\varphi(y)$ for each $x,y\in[0,1]$, then we have that
$$
\operatorname{Tr} K=\sum_i|\langle\varphi,e_i\rangle|^2=\|\varphi\|^2=\int_0^1|\varphi(x)|^2dx=\int_0^1k(x,x)dx.
$$
Is there an example of a non-negative self-adjoint trace class operator such that $\operatorname{Tr}K\ne\int_0^1k(x,x)dx$ or is it possible to prove that the trace is always equal to the integral of the kernel over the diagonal?
Any help is much appreciated!
 A: Note that the diagonal $\Delta=\{(x,x)\mid x\in[0,1]\}$ is a measure zero set, so it is not a priori clear what the meaning should be of a symbol such as $k(x,x)$. But we do have the following

Theorem: $K$ has an eigenbasis $(e_i)_{i\in\mathbb{N}}$ with corresponding eigenvalues $(\lambda_i)_{i\in\mathbb{N}}$. The function $q: [0,1]^2 \rightarrow \mathbb{C}$ defined by $q(x,y):=\sum_{i=1}^\infty \lambda_i e_i(x) \bar{e}_i(y)$ satisfies $k(x,y)=q(x,y)$ almost everywhere, and if we put $k(x):=q(x,x)=\sum_{i=1}^\infty \lambda_i \lvert e_i(x) \rvert^2 $, then $\mathrm{Tr }\, K = \int k(x)\,dx$.

Proof: Since $K$ is self-adjoint and compact, the spectral theorem ensures the existence of an ONB $(e_i)_{i\in\mathbb{N}}$ such that, for any $\psi\in L^2([0,1],\mathbb{C})$, we have
$$
K\psi=\sum_{i=1}^\infty \lambda_i \langle e_i,\psi\rangle e_i.
$$
Furthermore, since $K$ is Hilbert-Schmidt, we have $\sum_{i=1}^\infty \lvert \lambda_i\rvert^2<\infty$. Fixing representatives $e_i:[0,1]\rightarrow \mathbb{C}$ for the basis $(e_i)_{i\in\mathbb{N}}$, it follows that the series
$$
q(x,y):=\sum_{i=1}^\infty \lambda_i e_i(x) \bar{e}_i(y)
$$
is convergent in $L^2([0,1]^2,\mathbb{C})$, and since we have
\begin{align}
\int \bar{\phi}(x) k(x,y) \psi(y) \, dxdy & = \langle \phi , K\psi\rangle= \sum_{i=1}^\infty \lambda_i \langle \phi, e_i\rangle \langle e_i,\psi\rangle \\
&= \sum_{i=1}^\infty \lambda_i \int \bar{\phi}(x) e_i(x) \bar{e}_i(y) \psi(y)\, dxdy = \int \bar{\phi}(x) q(x,y) \psi(y)\, dxdy
\end{align}
for all $\phi,\psi\in L^2([0,1],\mathbb{C})$, it follows that $q=k$ almost everywhere.
Now we make use of the assumption that $K$ is trace class: We have $\sum_{i=1}^\infty \lvert \lambda_i\rvert<\infty$. Thus, we can define $k(x):=q(x,x)=\sum_{i=1}^\infty \lambda_i \lvert e_i(x)\rvert^2$, and then we have $k\in L^1([0,1],\mathbb{C})$. Furthermore, we have
$$
\int k(x)\,dx = \sum_{i=1}^\infty \lambda_i \int \lvert e_i(x)\rvert^2\, dx = \sum_{i=1}^\infty \lambda_i = \mathrm{Tr }\, K,
$$
finishing the proof.
This solution does not make use of non-negativity of K. To make the connection to the answer by Christian Remling, note that $K$ has a non-negative square root $A=\sqrt{K}$, and we have
$$
A\psi=\sum_{i=1}^\infty \sqrt{\lambda_i} \langle e_i,\psi\rangle e_i.
$$
Since $K$ is trace class, it follows that $A$ is Hilbert-Schmidt, and as above we find a kernel for $A$, namely
$$
a(x,y)=\sum_{i=1}^\infty \sqrt{\lambda_i}e_i(x)\bar{e}_i(y).
$$
Then we have
$$
q(x,y) = \sum_{i=1}^\infty \lambda_i e_i(x)\bar{e}_i(y) = \int a(x,t)a(t,y) \, dt ,
$$
and in particular $k(x)=\int a(x,t)a(t,x) \, dt$. Here, it is also possible to remove the assumption that $K$ is non-negative, by noting that the polar decomposition $K=U\lvert K \rvert=(U\lvert K \rvert^{1/2})\lvert K \rvert^{1/2}$ affords us with a factorization of $K$ into a product of Hilbert-Schmidt operators.
Questions of this sort have received some attention in the literature, see for instance the paper 'Traceable Integral Kernels on Countably
Generated Measure Spaces' by Brislawn. There is also a related question on MO, When is an integral transform trace class.
Brislawn, Chris, Traceable integral kernels on countably generated measure spaces, Pac. J. Math. 150, No.2, 229-240 (1991). ZBL0724.47014. 
A: For positive $K$ we're in good shape, after addressing the issue I mentioned in my comment. We can take a positive square root $A=K^{1/2}$, which is Hilbert-Schmidt, and $\|K\|_1 = \|A\|_2^2$. Moreover, Hilbert-Schmidt operators have square integrable kernels, and the Hilbert-Schmidt norm of the operator equals the $L^2$ norm of the kernel. In other words, if we denote the kernel of $A$ by $a(x,y)$, then
$$
\textrm{tr}\, K= \|K\|_1=\int\!\!\int |a(x,y)|^2\, dxdy = \int dx\left( \int dy\, a(x,y)a(y,x)\right)
$$
and this is the desired formula because $k(x,y)=\int a(x,t)a(t,y)\, dt$ works as a kernel for $K=A^2$.
(Note that the small problem I pointed out got taken care of automatically, because a specific version of $k$ is delivered to us.)
A: Indeed, if $k$ is continuous and $K$ is self-adjoint and nonnegative, then $K$ is trace class and
$$\operatorname{Tr}(K) = \int_0^1 k(t, t)dt$$
This is a corollary of a theorem of Mercer: Functions of positive and negative type, and their connection the theory of integral equations, Phil. Trans. Roy. Soc. London (A) 209 (1909) 415–446.
The proof is short and elementary, and it generalizes to other compact spaces; see e.g. Equivalent definitions of the trace of a Hilbert-Schmidt operator
