Telerik blogs
Telerik R2 2019 Release_870x220

Following your requests for JustMock, with R2 2019 we provide support for Azure Pipeline with build agent hosted in the cloud, auto resolving of test context when using asynchronous tasks, verification of method call prerequisites, throw an exception from an asynchronous task and new .NET Core project templates for Visual Studio.

Support for Azure Pipeline with Build Agent Hosted in the Cloud

Until now JustMock supported Azure Pipeline with build agent hosted on premises server. This was a limitation due to the requirement JustMock to be installed on the server. With R2 2019 we are officially providing installation free option for the Azure Pipeline task.

The installation free option is available for build agents hosted on premises servers and in the cloud. To configure this new option go to the JustMock options section in the JustMock VSTest task, which you should add to your build pipeline after installing our Telerik JustMock Tests v.2 extension. Simply fill the 32 and 64 bit JustMock profiler path as it is done in the following screenshot:

Azure Pipeline

 

Of course, you should first make sure that the 32 and 64-bit JustMock profiler dlls are available on the build agent machine. I have personally done that by adding them to the source control in a separate folder named "Lib". This way I ensure that regardless if the build agent is on premisses or in the cloud the profilers dll will be available. Lastly, a verification of the correctness of the specified path is always a good practice.

Support for Verification of Method Call Prerequisites

There are those test cases where the developer should make sure that a certain number of methods were already executed before verifying that a particular method has returned a correct value. This is why we have implemented a new feature for verification of method call prerequisites.

To better illustrate the benefit of this feature I will give the following example. Imagine that you want a certain collection to be returned by a method only after an Init method is called for all elements in that collection. How would you verify that?

Here is a code example demonstrating exactly how this test case could be verified:

// Arrange
var barCollection = new List<IBar>()
{
    Mock.Create<IBar>(),
    Mock.Create<IBar>(),
    Mock.Create<IBar>()
};
var barContainer = Mock.Create<IBarContainer>();
Mock.Arrange(() => barContainer.Elements)
    .ReturnsCollection(barCollection)
    .AfterAll(barCollection.Select(bar => Mock.Arrange(() => bar.Init())).ToArray());
 
// Act
barCollection.ForEach(bar => bar.Init());
var actualCollection = barContainer.Elements;
 
// Assert - verify that all prerequisites are met
Mock.Assert(barContainer);

For more information please check our documentation article about this feature.

Auto Resolving of Test Context When Using Asynchronous Tasks

In many situations when creating a mock for a static member the developer writing the test should think if this static member can be called from an async task and search for the correct JustMock API to handle this scenario. Until now the arrangement of such static member had to be done with calling the OnAllThreads method after all other expectations. With R2 2019 we have simplified this process by implementing an automatic resolving of test context when using asynchronous tasks. This means that if the developer has made an arrangement for a static member or future creation of object instance those arrangements will be valid out of the box for all async tasks created by the test method. 

Throw an Exception from an Asynchronous Task

Have you ever wonder how to simulate the return of a failed asynchronously executed task with specific exception? Me too as so do our clients. This is why we have implemented support for throwing a specified exception for a target asynchronous call causing returned task to fail. Here is example of how such arrangement should be done:

Mock.Arrange(() => foo.AsyncExecute()).ThrowsAsync<ArgumentException>();

For more information please check our documentation article about this feature.

.NET Core Project Templates

As we promised we are adding .NET Core project templates for Visual Studio. With those project templates a developer could create a test project for .NET Core using JustMock with few clicks.

Net Core test project template

Sign Up for the Webinar

To see the new release in action, please join us on the Telerik R2 2019 webinar, on Wednesday, May 29th @ 11:00 am - 12 pm ET.

Save My Seat

Share Your Feedback

Feel free to drop us a comment below sharing your thoughts. Or visit our Feedback portal and let us know if you have any suggestions or if you need any particular features.

Try out the latest:

JustMock

In case you missed it, here are some of the updates from our previous release.


Mihail Vladov
About the Author

Mihail Vladov

Mihail Vladov is a Software Engineering Manager at Progress. He has more than a decade of experience with software and product development and is passionate about good software design and quality code. Mihail helped develop the WPF controls suite and Document Processing libraries which are used by thousands of developers. Currently, he is leading the JustMock team. In his free time, he loves to travel and taste different foods. You can find Mihail on LinkedIn.

Related Posts

Comments

Comments are disabled in preview mode.