title: Click: Test click.group commands without running their code
body: <p>I´m currently writing tests for my application and therefore, I have to test some <code>click.group</code> commands I defined:</p>
  
  <p>Let´s say I defined them like:</p>
  
  <pre><code>@click.group(cls=MyGroup)
  @click.pass_context
  def myapp(ctx):
      init_stuff()    
  
  @myapp.command()
  @click.option('--myOption')
  def foo(myOption: str) -&gt; None:
      do_stuff() # change some files, print, create other files
  </code></pre>
  
  <p>I know that I could use the <code>CliRunner from click.testing</code>. However, I just want to make sure, that the command is called, but I DONT WANT it to execute any code (for example by applying the <code>CliRunner.invoke()</code>).</p>
  
  <p>How could this be done? 
  I couldn´t come up with a solution using mocking with <code>foo</code> for example. Or do I have to execute code lets say using the <code>isolated_filesystem()</code> which <code>CliRunner</code> provides?</p>
  
  <p>So the question is: What would be the most efficient way to test my commands when defined like shown above?</p>
  
  <p>Many thanks in advance</p>