Improvements for .NET Core and fixes for complex static mocking scenario are here in the latest update of Telerik JustMock.
We are excited to bring you the latest service pack release for Telerik JustMock. In this blog post I will elaborate on the important improvements and bug fixes we have introduced.
System.InvalidCastException : Unable to cast object of type 'System.AppDomainSetup' is thrown after upgrading to .NET Core 3.0
We have received reports that in some cases when a DoNothing or Throw methods are used, an InvalidCastException is thrown for cast to “System.AppDomainSetup” when the tests are executed for a .NET Core 3.0 project. This issue is now fixed.
Mock.Reset is not executed for an arrangement made in a test setup method and when the corresponding test cleanup method is not defined
We have encountered a problem where a conditionally created mock created in a test setup method has leaked for other tests as well. Additional requirements for the bug to occur were the lack of defined corresponding test cleanup method and the project to target .NET Core. We have fixed the issue by improving the implicit generation of a test cleanup method when missing and calling Mock.Reset from the newly-generated method.
Mocking a static method not directly used in a test execution logic messes with the arrangements of the test
This is a bit of a complex scenario. To solve the problem, you would have to create a mock with loose behavior of specific class. Let’s call it Foo. Then you will need to create a future mocking of Foo with returning the already created foo mock. Then in a static class, let’s call it Bar, a static field must be initialized with value from a newly-created instance of Foo. Later in the test when an arrangement is made for some of the static methods of Bar, the behavior of the foo mock is not taken into account and this results in unwanted recursive loose behavior instead of just loose behavior. Like I said it’s a bit of a complex scenario. Fortunately, it's fixed now.
Try Telerik JustMock Out and Share Your Feedback
The R3 2019 Service Pack is already available for download in customers’ accounts. If you explore JustMock, you can learn more. It comes with a 30-day free trial, giving you some time to test its capabilities.
We would love to hear what you think, so should you have any questions and/or comments, please share them in our Feedback Portal.
You can also check our Release History page for a complete list of the included improvements.