How to integrate a total derivative?

That's not how it works. If you have

$$ \frac{\partial f}{\partial x} = y, \quad \frac{\partial f}{\partial y} = x $$

You can only integrate one variable at a time. For example integrate w.r.t $y$

$$ f(x,y) = \int x\ dy = xy + g(x) $$

Then taking the partial w.r.t $x$ of both sides $$ \frac{\partial f}{\partial x} = y + \frac{dg}{dx} $$

Thus $dg/dx = 0$ or $g(x) = c$. Then the final solution is

$$ f(x,y) = xy + c$$

which varies up to a constant, as expected.


If you prefer to use your notation, it looks something like

$$ df = x \ dy + y \ dx $$ $$ \int \frac{\partial f}{\partial y}\ dy = \int x \ dy + \int y\frac{\partial x}{\partial y} dy $$

Since $x$ and $y$ are independent, $\partial x/\partial y = 0$ and you get $$ f(x,y) = xy + g(x) $$

Note that the extra term is only constant w.r.t $y$ so we say it's some function of $x$


In terms of path integrals, what you do when get $\int x \, dy + \int y \, dx = xy + yx$ is that you calculate the two integrals along different paths, the first along a "vertical" path and the other along a "horizontal" path. What you should to is do calculate both along the same path:

Let's take a linear path $\gamma$ from $(0,0)$ to $(x_0, y_0)$. This can be parameterized by $(x, y) = (t x_0, t y_0)$ where $t$ runs from $0$ to $1$. The integral then becomes $$ \int_0^1 (t \, x_0)(dt \, y_0) + \int_0^1 (t \, y_0)(dt \, x_0) = x_0 y_0 \int_0^1 t \, dt + y_0 x_0 \int_0^1 t \, dt \\ = \frac12 x_0 y_0 + \frac12 x_0 y_0 = x_0 y_0 $$

In fact, in this case, since $x \, dy + y \, dx = d(xy)$ is an exact differential, any path between the two points will give the same result.