mattwhitfield / Unitverse

A unit test generation extension for Visual Studio that aims to always produce code that compiles - covering the basic cases automatically and preparing as much as it can for the complex cases.
MIT License
89 stars 20 forks source link

Support for Shouldly #203

Closed Hefaistos68 closed 1 year ago

Hefaistos68 commented 1 year ago

Not a problem, just my preference to use Shouldly instead of the usual Assert. expressions. Now I have to replace all Assert.That with the much nicer to read Should.Throw<>() etc.

Describe the solution you'd like Would be nice to be able to select Shouldly as option for the generated Asserts.

mattwhitfield commented 1 year ago

I can add that - seems pretty similar to FluentAssertions 👍

Thanks for the idea

mattwhitfield commented 1 year ago

So ^ is a first pass - I think it does what you'd want. I haven't added examples to the docs yet, and some bits are a little rough (like you can select both 'Use FluentAssertions' and 'Use Shouldly' in the options (in which case it would use FluentAssertions). But it should still find & match the option based on existing references in test projects, and you can specify it when creating test projects etc. 👍

Hefaistos68 commented 1 year ago

You are a quick one, wow. Will check it out asap. Thanks for your efforts and a really useful extension!

mattwhitfield commented 1 year ago

Going to close this - if there are any issues, please do let me know. Also, VS Marketplace reviews are appreciated! 😁

Hefaistos68 commented 1 year ago

Seeing a small glitch with boolean returns that should end up having a result.ShouldBeTrue/False but instead there are Assert.Fail, have to check more. Reviews coming up. Sent to a few colleagues too.

mattwhitfield commented 1 year ago

I think that is as designed - the generator doesn't inspect the content of methods - so it doesn't know if it should be true or false - so it emits Assert.Fail so you don't end up with an 'accidentally' passing test.

Thanks in advance for the reviews ❤️

Hefaistos68 commented 1 year ago

Understand, will think about it. Good work.