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

Issues with unit tests #4

Closed
wants to merge 2 commits into from
Closed

Conversation

gps035
Copy link

@gps035 gps035 commented Oct 13, 2017

I saw this library the other day, and thought it would be useful for unit testing, but ran into some issues.
I've added a commit with some new tests that should demonstrate the issues.

It seems that whenever the Assert class (from Microsoft.VisualStudio.TestTools.UnitTesting) is used within a PoseContext.Isolate entry point, a InvalidProgramException is thrown with the message Common Language Runtime detected an invalid program.

I'm not sure why that is, but I tried with another assertion library, Shouldly, and this time the assertions work, but the problem is that any exceptions from failed assertions (any exceptions actually), are wrapped in a TargetInvocationException. This means that the failed unit tests have error messages that are not as useful as they could be.

I've added another commit that simply catches that exception and rethrows the inner exception, which solves that particular issue, but I don't know if that is ideal. I'm not very familiar with the project and don't know if the original exception is needed or useful.

Perhaps the best way to deal with this would be to do all asserting outside of the Isolate method.

@tonerdo
Copy link
Owner

tonerdo commented Oct 18, 2017

@gps035 Thanks for the intention to contribute. Usually Assert statements shouldn't be isolated, you should instead isolate specific methods and use the result in a pure assert. I will look into the exception thrown when Assert is isolated, thanks for that.

@tonerdo tonerdo closed this Oct 18, 2017
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.

2 participants