The integration does not work as expected when the tests are run on the command line outside Visual Studio via dotnet test command. The coverage is used as Microsoft.CodeCoverage NuGet package.
Asynchronous test execution might be run in a separate thread (it depends of the environment and it is completely transparent) which causes arrangements to lose their context. That is why the expected mocked return value for DateTime.UtcNow calls the original code and finally the test fails.
Implement integration between JustMock and the code coverage provided by Visual Studio for .net core applications.
Steps representing the missing feature:
Create a .net core test project.
Include JustMock tests.
Execute the tests with code coverage provided by Visual Studio Enterprise.
Visual Studio debugger arrowhead pointer is messed when profiler is enabled with .Net Core 2.1, in VS2107/2019
Steps
Code Snippet
Mock.SetupStatic(typeof(ElasticOperationsHelper), Behavior.Strict, StaticConstructor.Mocked);
Mock.Arrange(() => elasticRepository.IndexDocumentInElastic<IndexDocText>(Arg.IsAny<IndexDocText>(), Arg.IsAny<string>(), null)).Returns(response);
While debugging it's found the arrowhead pointer of VS debugger is messed up and pointing to wrong line numbers. It's quite difficult to develop unit tests at this situation. Is there any resolution of this problem.
I found an article in the support page has been declined due to same problem. Is this totally dependent on "CLR" fix and .Net profiler. If so could you please provide me the Bug details of Microsoft for the same?
I would also like to know why it's necessary to have profiler enabled for scenarios like "Static Mocking", "Non virtual method mocking", "Private Mocking" etc.
Is this only happening for .Net core?
Hyland Software is evaluating this product as their Mocking framework for unit testing of all .net core projects.
If there is no solution, how can any prospective customer consider this as a good fit for their usage? If there is any workaround possible at this moment?
After upgrading to .NET Core 3.0 an exception is thrown for some of the JustMock methods like DoNothing() and Throw(). In the case for DoNothing() the exception is thrown only for methods that are returning value.
Here is the full exception:
System.InvalidCastException : Unable to cast object of type 'System.AppDomainSetup' to type 'YourType'
The CallMethod of the PrivateAccessor is using reflection to invoke the required method. When an exception is thrown inside that method it will be wrapped by the reflection in a TargetInvocationException which is received in the test method.
Instead of the TargetInvocationException, throw the original exception.
I just installed it onto desktop, loaded Visual Studio 2019 (Ent) and i see no visual reference or otherwise to JustMock.
Honestly If i had have spent the $$ by now i'd have uninstalled and given up.
Values from already mocked methods are not taken into account when initializing a static constructor from the Telerik.JustMock.PrivateAccessor class.
Here is an example: PrivateAccessor.ForType(typeof(Foo)).SetField("someStringField", "stringvalue");
A workaround is to call the: Mock.Intercept(typeof(Foo)); before calling the PrivateAccessor.