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

Mocks being created with Moq even if NSubstitute is configured #242

Closed marcoschneidertui closed 5 months ago

marcoschneidertui commented 5 months ago

Describe the bug Hi, I recently started using your tool. I am currently wondering why my Mocks being created with Moq, even that I have selected NSubstitute to be the mocking framework. NSubstitute nuget package is already added to my Test Project.

To Reproduce I add my current configuration here. This is how the result looks like on my machine.

2024-04-29 08_23_06-Clipboard

This is my config: unitTestGeneratorConfig.txt

Thanks for some support on this.

mattwhitfield commented 5 months ago

Hello - have a look at this page - https://mattwhitfield.github.io/Unitverse/configuration.html - particularly the section that starts 'If you are not sure how a particular option has been configured'. You can hold down the Control key while clicking generate tests and it will tell you how that option was selected. From the look of your screenshot, it would be because you have the Moq nuget package installed.

So, my question really is - are you really saying 'I have multiple mocking packages installed in my test project - but it picks Moq over NSubstitute, even though I have NSubstitute installed as well'?

marcoschneidertui commented 5 months ago

Hi, yes I have both mocking frameworks installed. And when I remove moq nuget, the class is generated with NSubstitute. So it seems, independent of the setting, if moq is found that has priority

mattwhitfield commented 5 months ago

OK, leave that with me. I will make it so that framework detection doesn't override a setting that is valid.

However, in the mean time, you can create a settings file that just turns framework auto-detection off for that project - the settings files work much like editorConfig files. If the documentation doesn't make it clear what to do, then please do let me know... 👍

mattwhitfield commented 5 months ago

This should be resolved in 0.204 - please let me know if it works for you :)

marcoschneidertui commented 5 months ago

Hi Matt, yes it is working fine now. Thank you for the quick fix, highly appreciated. Great tool!