title: No test coverage when tests are in a different package
body: <p>I have integration tests which are located in a separate directory. Those tests run my http server in the same process via net/http/httptest. My tests run but I get no coverage.</p>
  
  <p>Here is a very simplified example not using http for brevity.
  Directory layout:</p>
  
  <pre><code>$GOPATH/src/go-test
    hello
      hello.go
    itest
      integration_test.go
  </code></pre>
  
  <p><strong>hello.go</strong></p>
  
  <pre><code>package hello
  
  func Hello() string {
      return "hello"
  }
  </code></pre>
  
  <p><strong>integration_test.go</strong></p>
  
  <pre><code>package itest
  
  import (
      "go-test/hello"
      "testing"
  )
  
  func TestHello(t *testing.T) {
      s := hello.Hello()
      if s != "hello" {
          t.Errorf("Hello says %s", s)
      }
  }
  </code></pre>
  
  <p>Run the test:</p>
  
  <pre><code>$ go test -v -coverpkg ./... ./itest
  === RUN   TestHello
  --- PASS: TestHello (0.00s)
  PASS
  coverage: 0.0% of statements in ./...
  ok      go-test/itest   0.001s  coverage: 0.0% of statements in ./...
  </code></pre>
  
  <p>Another attempt:</p>
  
  <pre><code>$ go test -v -coverpkg all ./itest
  === RUN   TestHello
  --- PASS: TestHello (0.00s)
  PASS
  coverage: 0.0% of statements in all
  ok      go-test/itest   0.001s  coverage: 0.0% of statements in all
  </code></pre>
  
  <p>Notice that coverage is 0%.</p>
  
  <p>According to <code>go help testflag</code>:</p>
  
  <pre><code>-coverpkg pattern1,pattern2,pattern3
      Apply coverage analysis in each test to packages matching the patterns.
      The default is for each test to analyze only the package being tested.
      See 'go help packages' for a description of package patterns.
      Sets -cover.
  </code></pre>
  
  <p>How can I get the real coverage when my tests are in a different package?</p>
  
  <pre><code>$ go version
  go version go1.10 linux/amd64
  </code></pre>