How can I render my form? I create a module and I create a template for that .

I use this code in mymodule.module :

function mymodule_theme($existing, $type, $theme, $path) {
  return [
    'moduletheme' =&gt; [
      'render element' =&gt; 'form',
      'variables' =&gt; array('test_var' =&gt; NULL),
    ],
  ];
}


And I use this code in mymodule/src/Form/MymoduleForm.php :

public function buildForm(array $form, FormStateInterface $form_state) {
    $forms['#theme'] = [
        '#theme' =&gt; 'moduletheme',
        '#test_var' =&gt; $this-&gt;t('Test Value'),
    ];
    return $forms;
}


And I use this code in mymodule/templates/moduletheme.html.twig :

&lt;p&gt;Test twig template!&lt;/p&gt;
&lt;p&gt;test_var: {{ test_var }}&lt;/p&gt;


But when I clear cache and refresh my module page , I just see :

Test twig template!
test_var:


How can I fix this problem in drupal 8 ?
Remove the '#' from the form field key and clear cache. $forms['theme'] instead of $forms['#theme'].

$forms['theme'] = [
    '#theme' =&gt; 'moduletheme',
    '#test_var' =&gt; $this-&gt;t('Test Value'),
];