If you mean testing as in unit testing, Test offers the @inferred macro. If you mean testing as in checking what the return type will be before running g, you can also do this, but not through any exported methods (so beware).
You can use Base._return_type and Base.return_types
I need to check the returned type of functions when parsing expressions. I guess I could also use code_typed for doing this (right now I don’t really want to handle two representations: Typed CodeInfo and Expressions ).
In comparison with Base.return_types, It seems that Base._return_type outputs a more general but not too large type. So I guess, Base._return_type is the way to go.