We exactly solve the one-dimensional boost-invariant Boltzmann equation in the relaxation time approximation for arbitrary shear viscosity. The results are compared with the predictions of viscous and anisotropic hydrodynamics. Studying different non-equilibrium cases and comparing the exact kinetic-theory results to the second-order viscous hydrodynamics results we find that recent formulations of second-order viscous hydrodynamics agree better with the exact solution than the standard Israel-Stewart approach. Additionally, we find that, given the appropriate connection between the kinetic and anisotropic hydrodynamics relaxation times, anisotropic hydrodynamics provides a very good approximation to the exact relaxation time approximation solution.