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.
Hello,
According to the JustMock documentation, to validate a method on the mock was called it should be done like so:
[TestMethod]
public void ShouldThrowExceptionWhenMustBeCalledSetupIsNeverInvoked()
{
// Arrange
var foo = new Foo();
Mock.Arrange(() => foo.Execute()).MustBeCalled();
// Assert
Assert.Throws<AssertFailedException>(() => Mock.Assert(foo));
}
When I do that, the application fails to compile saying the type AssertFailedException does not exist, even though I have the using statement for the Telerik.JustMock assembly at the top of my file. If I try to fully qualify it like so:
Assert.Throws<Telerik.JustMock.Xunit.AssertFailedException>
I get the same message for the "Xunit" namespace.
I know that the type should exist since when I run the test asserting a different type of Exception, the test fails saying it expects an exception of type Telerik.JustMock.Xunit.AssertFailedException.
I am attaching a couple of images that illustrate the problem.
Thank you.
Currently, there are a lot of JustMock project templates with different targeted categories. There are templates targeting just one search category and there are other templates targeting different categories.
Optimize the templates to be available in all relevant search categories and lower their number.
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'
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.
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.
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.