'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
Solution 1:[1]
Is there a way to ignore test errors coming from third party packages during unit tests?
No, not in your case because the test is not "from third party package": The test is yours and it fails. The fact that your code calls a function from a "third party package" has no meaning here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Volker |

