title: MockK's spyk how to overwrite constructor?
body: <p>I currently try to test a class as a spy object that normally initialize a database connection in the constructor. The a simplified version of the class looks like this. </p>
  
  <pre><code>class classToTest(){
      val connection:Connection
  
      init {
          connection = DatabaseConnection(url="127.0.0.1")
      }
  
      fun methodA():Int{
         return 3
      }
  }
  </code></pre>
  
  <p>Now i try to test the methods of my classToTest in the following way (simplified).</p>
  
  <pre><code>class TestClass(){
      var connection = mockk&lt;DatabaseConnection&gt;()
      var dbh = spyk(ClassToTest())
  
      @Test
      fun testMethodA(){
         assertEquals(dbh.methodA,3)
      }
  }
  </code></pre>
  
  <p>The problem is now that my test can not start because i don't know how to overwrite the init function that may connection mock is used instead of initialize a connection object. Thanks for help.</p>