Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

[Refactor] Check error types in tests. #803

Open
arberiii opened this issue May 21, 2020 · 1 comment
Open

[Refactor] Check error types in tests. #803

arberiii opened this issue May 21, 2020 · 1 comment
Labels
Go Issue requires to write code using Go language maintainability

Comments

@arberiii
Copy link
Member

What is frustrating you?
Test cases that expect errors usually pass if it has any error, which is not correct if the error is different from what is expected.
For example:
Test case struct has the field:

Then checking the expected behavior is done in this way:
if testCase.expHasErr {
assert.NotEqual(t, nil, err)

Your solution
Tests should pass only if the error type is precisely the one expected.

@arberiii arberiii added maintainability Go Issue requires to write code using Go language labels May 21, 2020
@arberiii arberiii changed the title [Refactor] Check error types in tests [Refactor] Check error types in tests. May 21, 2020
@magicoder10
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Go Issue requires to write code using Go language maintainability
Projects
None yet
Development

No branches or pull requests

2 participants