How can I make fun of objects in the new world of coreclr?

I always used Moq for mocking external dependencies during unit testing. Now, when I try to make my code completely cross-platform, I want my unit tests to run on Linux as well, and so I am aiming for my coreclr50 project.

The problem is that I cannot find any mocking libraries that will allow me to make fun of on coreclr. LightMock.vNext tried to do this, but this requires creating the mock classes manually, which is not convenient.

I wonder how people test their MVC 6 controllers?

+5
source share
2 answers

The ASP.NET team seems to be using Moq https://github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNet.Mvc.Core.Test/project.json :

"dnxcore50": { "dependencies": { "moq.netcore": "4.4.0-beta8" } } 
+2
source

NSubstitute is a great system. As far as I can see, they do not yet support coreclr support, but they have a migration request to GitHub:

https://github.com/nsubstitute/NSubstitute/pull/197

So, you can try to do it yourself or wait a bit. Mock was a good foundation, but as far as I remember, it was not supported for a long time. NSubstitute also has better syntax (at least IMHO :)

+1
source

Source: https://habr.com/ru/post/1240331/


All Articles