unit-testinggonomad

Is there a way to ignore test errors coming from third party packages during unit tests?


My tests are failing due to a 3rd party error that is irrelevant to the tests themselves. Basically some testserver I have to use fails to shutdown on Windows OS but actually runs fine.

I need to ignore the errors it generates, but they are in the defer part as below. Is there a way to completely ignore any errors coming from the first two lines?

func TestDoSomething(t *testing.T) {
    testServer := setupTestNomad(t) //contains 3rd party test server creation
    defer testServer.Stop()  //actually fails here in the 3rd party struct due to 3rd party code itself

    data := DoSomething()
    if data == nil { //data is not null and all is fine here
        t.Errorf("Failed, data null")
    }
}

Test dies because of this within their code

enter image description here


Solution

  • Moving it to another namespace didn't help nor did the above helpful comments.

    The testing.T struct I carry around and use to create a new Nomad Test server allows the 3rd party code to fail my test. Not using that and using a new object as below solves this problem.

    nomadTestUtil.NewTestServer(&testing.T{},...