Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert.InEpsilonSlice: include msgAndArgs on failed assertion #1454

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

VladPetriv
Copy link

Summary

Added the msgAndArgs parameter to the InEpsilon function for better error reporting in case of failed assertion.

Related issues

Closes #1324

Copy link
Collaborator

@dolmen dolmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need a regression test.

I expect that the test will also be a good base for further improvement (in separate PRs) in reporting errors such as the index of the mismatch.

@VladPetriv
Copy link
Author

Hi @dolmen, thank you for the quick review!

We also need a regression test.

Can you provide more details about which regression tests you are referring to in the testify project? Thank you!

@dolmen
Copy link
Collaborator

dolmen commented Oct 10, 2023

Related: #1231 (also about InEpsilonSlice)

@dolmen dolmen added pkg-assert Change related to package testify/assert bug labels Oct 10, 2023
@dolmen
Copy link
Collaborator

dolmen commented Oct 10, 2023

@VladPetriv

Can you provide more details about which regression tests you are referring to in the testify project? Thank you!

The test that you didn't write!

We need to augment TestInEpsilonSlice to check that msgAndArgs is passed and reported in case of a failing test.

@dolmen dolmen changed the title fix(InEpsilonSlice): Include msgAndArgs in InEpsilon for improved error visibility on failed assertion assert.InEpsilonSlice: include msgAndArgs on failed assertion Oct 10, 2023
@dolmen dolmen added the assert.InEpsilon About assert.InEpsilon and family label Oct 16, 2023
@dolmen
Copy link
Collaborator

dolmen commented Oct 30, 2023

This blocked by #1483 that must be merged first.

assert/assertions.go Show resolved Hide resolved
assert/assertions_test.go Outdated Show resolved Hide resolved
@dolmen dolmen added the hacktoberfest-accepted Hacktoberfest label Oct 30, 2023
@@ -1915,6 +1915,17 @@ func TestInEpsilonSlice(t *testing.T) {
0.04), "{2.2, 2.0} is not element-wise close to {2.1, 2.1} in epsilon=0.04")

False(t, InEpsilonSlice(mockT, "", nil, 1), "Expected non numeral slices to fail")

inEpsilonSliceMockT := new(mockTestingT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the variable to mockT for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert.InEpsilon About assert.InEpsilon and family bug hacktoberfest-accepted Hacktoberfest pkg-assert Change related to package testify/assert
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InEpsilonSlice doesn't append custom error message
2 participants