How do I programmatically render a view with contextual filters?
Basing on the code used by views_get_view_result(), I would use the following code, as code equivalent to the one you show in the question.

  $args = [$tid];
  $view = Views::getView('test_view');
  if (is_object($view)) {
    $view-&gt;setArguments($args);
    $view-&gt;setDisplay('block');
    $view-&gt;preExecute();
    $view-&gt;execute();
    $content = $view-&gt;buildRenderable('block', $args);
  }