Mathematica erroneously says this integral does not converge

Mathematica (as of v. 11.1.0) does not recognize that this special case of Frullani's integral converges:

Integrate[(ArcTan[a*x] - ArcTan[b*x])/x, {x, 0, Infinity}]
(* Integrate::idiv: Integral of ArcTan[a x]/x-ArcTan[b x]/x does not converge
on {0,\[Infinity]}.
Integrate[(ArcTan[a*x] - ArcTan[b*x])/x, {x, 0, Infinity}] *)


This should converge because the integrand is well-defined at zero and is $O(1/x^2)$ as $x \to \infty$.

Using the formula given, with $f(x) = \tan^{-1} (x)$, we should have

$$\int_0^\infty dx\,\frac{\tan^{-1}(a\,x)-\tan^{-1}(b\,x)}{x} = -\frac{\pi}{2} \ln \left(\frac{b}{a}\right)$$

NIntegrate crunches through just fine for $a = 1$ and $b = 2$.

NIntegrate[(ArcTan[1*x] - ArcTan[2*x])/x, {x, 0, Infinity}]
(* -1.08879 *)


This matches the exact result:

-(Pi/2)*Log[2/1] // N
(* -1.08879 *)


The integral does not converge if a and b are real and have opposite signs:

Series[(ArcTan[a*x] - ArcTan[b*x])/x, {x, Infinity, 2}]


As @shadowray pointed out, it does converge if a and b are positive and Integrate[] is passed that as an assumption. It also works with

Integrate[(ArcTan[a*x] - ArcTan[b*x])/x, {x, 0, Infinity}, Assumptions -> a < 0 && b < 0]


Although Integrate usually finds the condition in which the integral converges,

Integrate[Exp[-a x], {x, 0, Infinity}]


it's better to provide your own condition in the form of Assumptions.

Integrate[(ArcTan[a*x] - ArcTan[b*x])/x, {x, 0, Infinity}, Assumptions->{Re[a]>0, Re[b]>0}]


Integrate[(ArcTan[a*x] - ArcTan[b*x])/x, {x, 0, Infinity}, Assumptions->{Re[a]<0, Re[b]<0}]