title: Magento 2 : Proxy and Factory generation in unit tests scope
body: <p>I'm trying to create an Unit Test for a Magento 2 (version 2.2.0) Class that have a <a href="http://devdocs.magento.com/guides/v2.2/extension-dev-guide/proxies.html" rel="nofollow noreferrer">Proxy</a> Class injected in constructor.
  According to the Magento documentation, Proxies are generated code, like Factories.</p>
  
  <p>However, in Unit Test scope (code generation is in dev/tests/unit/tmp/generated directory), Proxies class are not generated. Only Factories is generated.</p>
  
  <p>Is there any reason why Proxy Class is not generated in Unit Test scope ?</p>
  
  <p>Hypothesis : according to the documentation, the Proxy injection should be in di.xml configuration file</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;type name="FastLoading"&gt;
      &lt;arguments&gt;
          &lt;argument name="slowLoading" xsi:type="object"&gt;SlowLoading\Proxy&lt;/argument&gt;
      &lt;/arguments&gt;
  &lt;/type&gt;
  </code></pre>
  
  <p>instead of injecting directly in constructor :</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>class FastLoading
  {
      protected $slowLoading;
  
      public function __construct(
          SlowLoading\Proxy $slowLoading
      ){
          $this-&gt;slowLoading = slowLoading;
      }
  }
  </code></pre>
  
  <p>So, inject a Proxy Class directly in constructor is a bad practice ?</p>
  
  <p>Another question for Factory generation in unit test scope, assuming the following Factory generated :</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>// dev/tests/unit/tmp/generated/code/Magento/Framework/Api/SearchCriteriaBuilderFactory.php
  namespace Magento\Framework\Api;
  
  class SearchCriteriaBuilderFactory
  {
  
      public function create(array $data = [])
      {
      }  
  }
  </code></pre>
  
  <p>What is the reason that the <strong>create()</strong> method generated is empty and so <strong>return null</strong> in unit test scope ?</p>
  
  <p>Thanks.</p>