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'
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.
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.
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.
Let's have the following class and unit test:
public delegate Task<int> SomeDelegate();
private async Task<int> DoSomeStuff()
JustMock public API lacks of convenient way to assert that particular task has been awaited. Potential workaround involves some "insider knowledge" that awaiting a Task internally results in a calls to some of its members.