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

Readable assertion messages on failure. #155

Merged

Conversation

CaptnCodr
Copy link
Member

@CaptnCodr CaptnCodr commented Jun 18, 2020

This fixes the assertion for Xunit and MsTest in #154 which prints on e.g.:
Ok "hello" |> should equal (Ok "world")

This result on failure:
Equals Ok "world" was Microsoft.FSharp.Core.FSharpResult`2[System.String,System.Object]

It's now printing:
Equals Ok "world" was Ok "hello"

Btw. I made some code cleanup.

@sergey-tihon
Copy link
Member

Thank you @CaptnCodr
Can you please add xUnit and MSTests tests for the case that you fix.

@CaptnCodr
Copy link
Member Author

CaptnCodr commented Jun 20, 2020

Thank you @CaptnCodr
Can you please add xUnit and MSTests tests for the case that you fix.

Yes, I did now.

While writing the tests we may consider to have an operator that returns a full exception to check it's types and messages. You come not far with throwWithMessage. e.g. throwException.

@CaptnCodr
Copy link
Member Author

In the last commit I merged the assertion syntax from Xunit to MsTest tests to have tests identical.

@CaptnCodr CaptnCodr requested a review from sergey-tihon June 24, 2020 06:57
[<TestMethod>] member test.
``11 should be greater than 10`` ()=
11 |> should be (greaterThan 10)

[<TestMethod>] member test.
``11.1 should be greater than 11.0`` ()=
``11,1 should be greater than 11,0`` ()=
Copy link
Member

Choose a reason for hiding this comment

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

Why you replaced . in test names by ,?

Copy link
Member Author

Choose a reason for hiding this comment

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

This tests with . doesn't show up in my test explorer. Should I undo this?

Copy link
Member

Choose a reason for hiding this comment

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

in VS?

Copy link
Member

Choose a reason for hiding this comment

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

I thought it already fixed microsoft/testfx#682

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, in VS 16.6.2.

Copy link
Member Author

Choose a reason for hiding this comment

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

I discovered that tests with period in their name are shown in a separate section within the test explorer.
In the coming PR I will undo this, because they're still there. I'm not satisfied with the , or other sequences (e.g. ..) inside the test name.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sergey-tihon sergey-tihon merged commit e8ce9c3 into fsprojects:master Jun 25, 2020
@sergey-tihon
Copy link
Member

Merged and released as v3.9.0
thank you @CaptnCodr for this contribution.

@cboudereau
Copy link

Thank you guys!

@CaptnCodr CaptnCodr deleted the bugfix/GenericAssertionMessage branch November 10, 2020 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants