Completed
Last Updated: 05 May 2023 06:59 by ADMIN
The issue has been detected for the first time in an attempt for integration between dotTrace 2022.3.2 and JustMock 2023.R1, but it also applies to dotCover and all subsequent versions after 2022.3 of both products.
Completed
Last Updated: 08 Dec 2022 10:07 by ADMIN

There are older releases with a version of 1.0.0.4 for the Telerik.JustMock.Console.exe and with the R3 2022 release, the version is 1.0.0.3.


Completed
Last Updated: 17 Oct 2023 12:32 by ADMIN
Created by: Ivo
Comments: 1
Type: Bug Report
1

A unit test run against a simple class using EntityFramework never completes, here's the code:

public class DbContext1 : DbContext
{
    public DbContext1(string connectionString)
    {
    }
}

public class Program
{
    private static readonly SemaphoreSlim _lock = new SemaphoreSlim(1, 1);

    public async Task Run()
    {
        await _lock.WaitAsync();
        try
        {
            await InsertDbRow();
        }
        finally
        {
            _lock.Release();
        }
    }

    private static async Task InsertDbRow()
    {
        await RetryWrapperAsync(async () =>
        {
            using DbContext1 dbContext = new DbContext1("con str");
            await dbContext.SaveChangesAsync();
        });
    }

    public static async Task RetryWrapperAsync(Func<Task> operation)
    {
        for (int i = 0; i < 3; i++)
        {
            try
            {
                await operation();
                break;
            }
            catch (Exception)
            {
                await Task.Delay(100);
            }
        };
    }
}

[TestClass]
public class ProgramTest
{
    private readonly DbContext1 mockContext1 = Mock.Create<DbContext1>();

    [TestInitialize]
    public void SetUp()
    {
        Mock.Arrange(() => new DbContext1("con str")).Returns(mockContext1);
    }

    [TestMethod]
    public async Task TestMethod()
    {
        // Arrange
        Program program = new Program();

        // Act
        await program.Run(); // <-- at this point the test hangs
    }
}

Adding do-nothing arrangement on mockContext.SaveChanges fixes the hang, but the expectation is that mock will handle this case by default and there is no need to be explicitly arranged.

Completed
Last Updated: 19 Sep 2022 10:47 by ADMIN
When the Azure pipeline is configured to use an agent with Windows-2022 the task Telerik JustMock VSTest v.2 reports the following error: ##[error]Error: Visual Studio 2015 is not found. Try again with a version that exists on your build agent machine.
Completed
Last Updated: 07 Dec 2022 11:53 by ADMIN

Referencing the nuget Microsoft.ApplicationInsights.AspNetCore V2.20.0 in the project that is tested leads to the VS 2019 code coverage failing to produce the report. Here are the steps to reproduce:

1. Create a project from the template ASP.NET Core Web API targeting .NET 5

2. Add a reference to the nuget package Microsoft.ApplicationInsights.AspNetCore V2.20.0

3. Create a unit test project from the C# JustMock Test Project (.NET Core) template.

4. Run the VS code coverage.

Expected result: the code coverage report is produced.

Actual result: there is no code coverage report

Completed
Last Updated: 22 Jun 2022 13:47 by ADMIN

Using the mentioned (or later) product version, the following simple test fails (throws NullReferenceException):

[TestMethod]
public void TestMethod()
{
    var cultureInfo = Mock.Create<CultureInfo>();
    var thisThrowsAnException = cultureInfo.Name;
}

One of the possible workarounds is to create a mock like this:

readonly string cultureName = CultureInfo.InvariantCulture.Name;
...
var cultureInfo = Mock.Create(() => new CultureInfo(cultureName));

Completed
Last Updated: 22 Jun 2022 13:46 by ADMIN

Using a different version of the NuGet package compared to the locally installed product could cause an unexpected error to occur, see the screenshot below:

image

 
Completed
Last Updated: 22 Jun 2022 13:45 by ADMIN

The case is reproducible (but might not be limited to) in a dedicated environment including Windows 10, JustMock R3.2021, Visual Studio 2019 and .NET 5. When the profiler is enabled the Visual Studio has problems with the test discovery and reports "Stack overflow" exception. The same applies to building solutions with Azure Function project.

CLR Stack from memory dump captured upon test execution:

000000CD7CE038D0 00007ffafb22d3b6 [GCFrame: 000000cd7ce038d0]
000000CD7CE03A40 00007ffafb22d3b6 [GCFrame: 000000cd7ce03a40]
000000CD7CE0A530 00007ffafb22d3b6 [PrestubMethodFrame: 000000cd7ce0a530] System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(System.Reflection.RuntimeAssembly, System.String)
000000CD7CE0A988 00007ffafb22d3b6 [GCFrame: 000000cd7ce0a988]
000000CD7CE0E3C0 00007ffafb22d3b6 [PrestubMethodFrame: 000000cd7ce0e3c0]  System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(System.Reflection.RuntimeAssembly, System.String)

... (omitted for brevity)

000000CD7CF72548 00007ffafb22d3b6 [GCFrame: 000000cd7cf72548]
000000CD7CF75F80 00007ffafb22d3b6 [PrestubMethodFrame: 000000cd7cf75f80] System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(System.Reflection.RuntimeAssembly, System.String)
000000CD7CF763D8 00007ffafb22d3b6 [GCFrame: 000000cd7cf763d8]
000000CD7CF79E10 00007ffafb22d3b6 [PrestubMethodFrame: 000000cd7cf79e10] System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(System.Reflection.RuntimeAssembly, System.String)
000000CD7CF7A268 00007ffafb22d3b6 [GCFrame: 000000cd7cf7a268]
000000CD7CF7DCA0 00007ffafb22d3b6 [PrestubMethodFrame: 000000cd7cf7dca0] System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]]..ctor()
000000CD7CF7DF10 00007FFA9B787B2A System.AppContext..cctor() [/_/src/System.Private.CoreLib/shared/System/AppContext.cs @ 16]
000000CD7CF7E340 00007ffafb2b6c93 [GCFrame: 000000cd7cf7e340]
000000CD7CF7ED18 00007ffafb2b6c93 [HelperMethodFrame: 000000cd7cf7ed18]
000000CD7CF7EE20 00007FFA9B7876B9 System.AppContext.Setup(Char**, Char**, Int32)

 

Completed
Last Updated: 12 May 2023 09:34 by ADMIN

Mock.Create<IPool>() fails with 

Telerik.JustMock.Core.MockException : Abstract type 'IPool' is not accessible for inheritance.
   In Telerik.JustMock.Core.MocksRepository.Create(Type type, MockCreationSettings settings)
   In Telerik.JustMock.Mock.<>c__39`1.<Create>b__39_0()
   In Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction) 

when trying to create a mock object from

public interface IPool
{
    object GetItem(in Struct a, out Class b);
}

 

Completed
Last Updated: 17 Oct 2023 12:33 by ADMIN

Considering the sample class

using Azure.Messaging.ServiceBus;

public class Class2
{
	private static ServiceBusSender messageToTopicSender;
	private static string topicName;

	public static void SetRequestTopicClient(string serviceBusConnectionString, string topName)
	{
		topicName = topName;

		ServiceBusClient serviceBusClient = new ServiceBusClient(serviceBusConnectionString);
		messageToTopicSender = serviceBusClient.CreateSender(topicName);
	}
}

and the following tests

[TestClass]
public class Class1Test
{
	[TestInitialize]
	public void SetUp()
	{
		Mock.Arrange(() => Class2.SetRequestTopicClient("", "")).DoNothing();
	}

	[TestMethod]
	public void TestA()
	{
		Class2.SetRequestTopicClient("", "");
	}
}

[TestClass]
public class Class2Test
{
	static ServiceBusClient serviceBusClient = Mock.Create<ServiceBusClient>();
	ServiceBusSender messageToTopicSender = Mock.Create<ServiceBusSender>();

	[TestInitialize]
	public void SetUp()
	{
		Mock.Arrange(() => new ServiceBusClient("conStr")).Returns(serviceBusClient);
		Mock.Arrange(() => serviceBusClient.CreateSender("myTopic")).Returns(messageToTopicSender);
	}

	[TestMethod]
	public void TestB()
	{
		Class2.SetRequestTopicClient("conStr", "myTopic");
	}
}

Executing the tests in order TestA -> TestB results in failed TestB, but changing the order or runining them standalone succeeds.The outcome of the tests should not be dependent of the execution order.

 

Completed
Last Updated: 10 Mar 2022 09:29 by ADMIN
Created by: Ivo
Comments: 0
Type: Bug Report
0

Considering the following simple scenario:

public class Class1
{
	private string arg1;

	public Class1(string arg1)
	{
		this.arg1 = arg1;
	}

	public Class3 Method(string arg)
	{
		throw new NotImplementedException();
	}
}

public class Class2
{
	static Class3 class3Instance; 

	public static void StaticMethod(string arg1, string arg2)
	{
		Class1 class1Instance = new Class1(arg1);
		class3Instance = class1Instance.Method(arg2);
	}
}

public class Class3
{

}

[TestClass]
public class Class2Test
{
	static Class1 mockClass1 = Mock.Create<Class1>();
	Class3 mockClass3 = Mock.Create<Class3>();

	[TestInitialize]
	public void SetUp()
	{
		Mock.Arrange(() => new Class1("arg1")).Returns(mockClass1);
		Mock.Arrange(() => mockClass1.Method("arg2")).Returns(mockClass3);
	}

	[TestMethod]
	public void TestB()
	{
		Class2.StaticMethod("arg1", "arg2");
	}
}

The test passes, but the debug trace output contains the warning message: "Calling one test method from another could result in unexpected behavior and must be avoided. Extract common mocking logic to a non-test method." even there is no call to the other test methods.

Completed
Last Updated: 10 Mar 2022 09:28 by ADMIN
An attempt to use Debug Window while debugging test code results in FileNotFoundException:

Exception thrown calling IDebugWindowPlugin plugin: System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
File name: 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Completed
Last Updated: 01 Dec 2021 14:07 by ADMIN
Created by: Jason
Comments: 2
Type: Bug Report
0

I've already created an issue in the JustMock repo, you can find it here: https://github.com/telerik/JustMockLite/issues/162. Below is the text from that issue...

I'm currently working on a PR to add JustMock to the suite of performance tests that currently exist in that repository. The problem is that some of the tests (like OneParameter and Callback) take a long time to finish for JustMock. I'm not sure why, but it's making it such that JustMock can't be added to the test suite. More to the point, the PR can't be accepted as-is because it would take too long to finish.

One thing Steve (owner of the repo) and I talked about is if the invocationCount value passed to the SimpleJobAttribute (which exists on both the MockingBenchmark and MockingBenchmark<T> classes) is reduced from 100,000 to something like 1,000, the tests then finish, but that doesn't address the underlying issue why these tests for JustMock slow down over repeated called.

There may be something in the benchmark tests with the way I've set things up with JustMock that may be incorrect. I've never used JustMock until today :). If there's something that I'm doing right, please let me know.

Completed
Last Updated: 12 May 2022 07:51 by ADMIN
A System.InvalidProgramException is thrown when async unit tests are executed inside Visual Studio with code coverage. The unit tests are testing an implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache.
Completed
Last Updated: 16 Sep 2021 08:37 by ADMIN

The following test is not working anymore since version JustMock_2021_2_615_4 but was working with JustMock_2021_1_326_1 and older versions:

public interface ITest
{
    void Test(string text);
}

[TestMethod]
public void MyTestMethod()
{
    var mock = Mock.Create<ITest>();
    Mock.Arrange(() => mock.Test("")).IgnoreArguments().OccursNever();
    Mock.Arrange(() => mock.Test(Arg.Matches<string>(a => a == "a"))).InOrder().OccursOnce();
    Mock.Arrange(() => mock.Test(Arg.Matches<string>(a => a == "b"))).InOrder().OccursOnce();


    mock.Test("a");
    mock.Test("b");

    Mock.Assert(mock);
}

If I remove the OccorsNever line, its working.
If I remove the 2 InOrder, its working.

Seems that something change there: https://www.telerik.com/support/whats-new/justmock/release-history/justmock-r2-sp1-2021

Completed
Last Updated: 16 Sep 2021 08:40 by ADMIN
Created by: Calvin
Comments: 3
Type: Bug Report
0

I filed a prior ThreadLeak:

Thread leak in JustMock (telerik.com)

 

I think I've found another one: (VS version 16.10.31321.278)

telerik_justmock_debugwindow_service_client!Telerik.JustMock.DebugWindow.Service.Client.ServiceHostMonitor.MonitorTimer_Elapsed

Apparently, the MonitorTimer_Elapsed code is running on a threadpool thread and it takes longer than 1 sec (perhaps it's waiting on a lock?).

Another timer tick occurs and the method is called again. Eventually, the ThreadPool runs out of threads and grows by about 1 thread per second (1Mb /sec leak)

In one dump 2Gig was used (1962 threads on the same MonitorTimer_Elapsed stack frame)

In that same dump there were 52 stacks with this frame:

telerik_justmock_debugwindow_service_client!Telerik.JustMock.DebugWindow.Service.Client.ConnectionSetupServiceClientBase`[[System.__Canon,mscorlib]].get_ServiceAvailable

(this was the same item as my prior report).

 

Completed
Last Updated: 16 Sep 2021 08:38 by ADMIN

The following test fails:

[TestMethod]
public void TestCallOrderWithInOrder()
{
	// Arrange
	var mockClass1 = Mock.Create<Class1>();
	var mockClass2 = Mock.Create<Class2>();

	Mock.Arrange(() => mockClass1.Method1())
		.InOrder();
	Mock.Arrange(() => mockClass2.Method1())
		.InOrder()
		.Occurs(2);
	Mock.Arrange(() => mockClass1.Method2())
		.InOrder();

	// Act
	mockClass1.Method1();

	mockClass2.Method1();
	mockClass2.Method1(); // <--- this call is not allowed by
						  //      InOrder clause currently 
						  //      and throws AssertFailedException

	mockClass1.Method2();

	// Assert
	Mock.Assert(mockClass1);
	Mock.Assert(mockClass2);
}

Completed
Last Updated: 14 Mar 2023 13:08 by Adam

Using elevated mocking mode (profiler enabled) with long path names for the test containers (above 260 characters) causes the following command:

dotnet test

to fail with error:

Testhost process exited with error: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Main(System.String[])
. Please check the diagnostic logs for more information.

Test Run Aborted.

Completed
Last Updated: 28 Jan 2021 15:47 by ADMIN

Hi Team,

The main telerik.com site is blocked in Sweden. I spoke to my VPN provider and got the exit IP address (217.64.148.92).

They said that the IP address used to be listed as an Iran IP in older GEO IP databases, which would explain why https://telerik.com is not working, even though it is from Stockholm

Can you please double check that your GEO IP database is not listing the Swedish IP address as being in Iran?

Thank you,

Markus

Completed
Last Updated: 02 Feb 2021 09:32 by ADMIN
Created by: Calvin
Comments: 7
Type: Bug Report
0

Thread leak in JustMock

I am a member of the Visual Studio Perf Reliability team

 

Recently, I’ve found several customer dumps with huge # of threads.

In this dump:

Watson : Cab Search (microsoft.com)

 

Thd_ThreadStack_telerik_justmock_debugwindow_service_client!Telerik.JustMock.DebugWindow.Service.Client.ConnectionSetupServiceClientBase`[[System.__Canon,mscorlib]].get_ServiceAvailable

2,136,997,888

 

Progress® Telerik® JustMock Feedback Portal

 

There are 2084 threads using 2G mem, most with the stack below:

This is caused by threadpool starvation: the JustMock call ties up a thread for more than 1 second, then another request comes in.

The CLR will create an additional thread after 1 second to satisfy the request. This keeps happening and creates thousands of threads, each with size 1Meg.

 


00 ntdll!NtWaitForMultipleObjects
01 KERNELBASE!WaitForMultipleObjectsEx
02 clr!WaitForMultipleObjectsEx_SO_TOLERANT
03 clr!Thread::DoAppropriateAptStateWait
04 clr!Thread::DoAppropriateWaitWorker
05 clr!Thread::DoAppropriateWait
06 clr!SOIntolerantTransitionHandler::SetNoException
07 clr!CLREventBase::WaitEx
08 clr!CLREventBase::Wait
09 clr!AwareLock::EnterEpilogHelper
0a clr!ThreadDebugBlockingInfo::PopBlockingItem
0b clr!DebugBlockingItemHolder::{dtor}
0c clr!AwareLock::EnterEpilog
0d clr!AwareLock::Enter
0e clr!AwareLock::Contention
0f clr!JITutil_MonReliableContention
10 Telerik_JustMock_DebugWindow_Service_Client!Telerik.JustMock.DebugWindow.Service.Client.ConnectionSetupServiceClientBase<Telerik.JustMock.DebugWindow.Service.Proxy.TraceEventsSubscriptionServiceProxy>.get_ServiceAvailable
11 Telerik_JustMock_DebugWindow_Service_Client!Telerik.JustMock.DebugWindow.Service.Client.SessionServiceClientBase<Telerik.JustMock.DebugWindow.Service.Proxy.MockRepositorySubscriptionServiceProxy>.KeepAliveTimer_Elapsed
12 System_ni!System.Timers.Timer.MyTimerCallback
13 mscorlib_ni!System.Threading.TimerQueueTimer.CallCallbackInContext
14 mscorlib_ni!System.Threading.ExecutionContext.RunInternal
15 mscorlib_ni!System.Threading.ExecutionContext.Run
16 mscorlib_ni!System.Threading.TimerQueueTimer.CallCallback
17 mscorlib_ni!System.Threading.TimerQueueTimer.Fire
18 mscorlib_ni!System.Threading.TimerQueue.FireNextTimers
19 mscorlib_ni!System.Threading.TimerQueue.AppDomainTimerCallback
1a clr!CallDescrWorkerInternal
1b clr!CallDescrWorkerWithHandler
1c clr!MethodDescCallSite::CallTargetWorker
1d clr!MethodDescCallSite::Call
1e clr!AppDomainTimerCallback_Worker
1f clr!ManagedThreadBase_DispatchInner
20 clr!ManagedThreadBase_DispatchMiddle::__l16::Cleanup::{dtor}
21 clr!ManagedThreadBase_DispatchMiddle
22 clr!ManagedThreadBase_DispatchOuter
23 clr!ManagedThreadBase_FullTransitionWithAD
24 clr!ManagedThreadBase::ThreadPool
25 clr!AppDomainTimerCallback
26 clr!ThreadpoolMgr::AsyncTimerCallbackCompletion
27 clr!UnManagedPerAppDomainTPCount::DispatchWorkItem
28 clr!ThreadpoolMgr::ExecuteWorkRequest
29 clr!ThreadpoolMgr::WorkerThreadStart
2a clr!Thread::intermediateThreadProc
2b kernel32!BaseThreadInitThunk
2c ntdll!__RtlUserThreadStart
2d ntdll!_RtlUserThreadStart

1 2 3 4