Skip to content

Readable assertion messages on failure.#155

Merged
sergey-tihon merged 8 commits intofsprojects:masterfrom
CaptnCodr:bugfix/GenericAssertionMessage
Jun 25, 2020
Merged

Readable assertion messages on failure.#155
sergey-tihon merged 8 commits intofsprojects:masterfrom
CaptnCodr:bugfix/GenericAssertionMessage

Conversation

@CaptnCodr
Copy link
Copy Markdown
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
Copy Markdown
Member

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

Comment thread src/FsUnit.MsTestUnit/FsUnit.fs
@CaptnCodr
Copy link
Copy Markdown
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
Copy Markdown
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.1 should be greater than 11.0`` ()=
``11,1 should be greater than 11,0`` ()=
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@cboudereau
Copy link
Copy Markdown

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