Unplanned
Last Updated: 30 Oct 2024 08:22 by ADMIN

We're using this DevOps task in our pipeline, however since yesterday we get the following warning:

##[warning]Task 'Telerik JustMock VSTest v.2' version 2 (JustMockVSTest@2) is dependent on a Node version (6) that is end-of-life. Contact the extension owner for an updated version of the task. Task maintainers should review Node upgrade guidance: https://aka.ms/node-runner-guidance

 

We're running it using a build agent hosted at the Azure DevOps cloud.

Unplanned
Last Updated: 16 May 2024 09:48 by ADMIN
Created by: Yosi
Comments: 4
Type: Feature Request
1

Hi.

i saw this: https://www.telerik.com/forums/how-can-i-mock-multiple-instances-of-a-struct

but still dont understand why JustMock works that way in the first place. why does it union struct mocks by value?

the above solution is only possible when i mock a struct i can change (and then add the id to it) but what about struct's from the framework that i cannot control? Is there a way to tell JustMock not to union mock structs?

Thanks,

Yosi

Unplanned
Last Updated: 08 Feb 2024 18:32 by Ivo

The issue is about interoperability between JustMock and AutoFixture. The unit test run can be 90% faster if all the fixtures are created before the JustMock arrangements.

Here is a sample code that figures out the issue:

[Fact]
public void Slow
{ 
    var fixture = new Fixture():

    var items1 = fixture.Create<List<Item>>();
    Nock.Arrange(() => ItemsRepository.GetItems1()).Returns(items1);

    var items2 = fixture.Create<List<Item>>();
    Nock.Arrange(() => ItemsRepository.GetItems2()).Returns(items2);

    var items3 = fixture.Create<List<Item>>();
    Nock.Arrange(() => ItemsRepository.GetItems3()).Returns(items3);

    var items4 = fixture.Create<List<Item>>();
    Nock.Arrange(() => ItemsRepository.GetItems4()).Returns(items4);
}

[Fact]
public void Fast()
{
    var fixture = new Fixture():

    var items1 = fixture.Create<List<Item>>();
    var items2 = fixture.Create<List<Item>>();
    var items3 = fixture.Create<List<Item>>();
    var items4 = fixture.Create<List<Item>>();

    Nock.Arrange(() => ItemsRepository.GetItems1()).Returns(items1);
    Nock.Arrange(() => ItemsRepository.GetItems2()).Returns(items2);
    Nock.Arrange(() => ItemsRepository.GetItems3()).Returns(items3);
    Nock.Arrange(() => ItemsRepository.GetItems4()).Returns(items4);
}

The test duration should not be dependent on the exact implementation.

Unplanned
Last Updated: 05 Feb 2024 13:46 by Christian
When mock generation is enabled and a mock code ends with unfinished Return setup VB compiler get into a broken state. Once in broken state the user has to manually build the code or go back in code editor in order to get into correct state.
Unplanned
Last Updated: 30 Nov 2023 08:54 by Christian
This request is about making feature parity with the existing functionality that currently supports C#.
Unplanned
Last Updated: 27 Jun 2023 09:47 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
1
In-Assembly Parallel (IAP) significantly reduces the time for test execution, but currently JustMock does not support it.
Unplanned
Last Updated: 23 Jun 2023 09:42 by ADMIN

Dear Telerik team,
It is nice to have a way to generate mocks.

But it is annoying to have lots of those messages for references in XML comments. I had to turn the feature off. Which might be the case for other customers too.

Maybe you want to have a look into it.


Unplanned
Last Updated: 10 May 2023 08:22 by ADMIN
ADMIN
Created by: Kamen Ivanov
Comments: 3
Type: Feature Request
5

			
Unplanned
Last Updated: 25 Apr 2023 15:53 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
1

JustMock interprets anonymous types as tuples. The sample below demonstrates the issue:

public interface IAnsweringService
{
    (int code, string desc) GetAnswer(string question);
}


[TestMethod]
public void AnswerToTheUniverseQuestionTest()
{
    var apiMock = Mock.Create<IAnsweringService>();

    var expectedAnswer = new { code = 42, desc = "Answer to the Ultimate Question of Life" };

    Mock.Arrange(() => apiMock.GetAnswer(Arg.AnyString)).Returns(expectedAnswer);

    var actualAnswer = apiMock.GetAnswer("What is a universe question answer?");

    Assert.AreEqual(expectedAnswer.code, actualAnswer.code);
    Assert.AreEqual(expectedAnswer.desc, actualAnswer.desc);
}
The test fails with error:

Telerik.JustMock.Core.MockException: The chained return value type '<>f__AnonymousType1`2[System.Int32,System.String]' is not compatible with the arranged method's return type 'System.ValueTuple`2[System.Int32,System.String]'

Unplanned
Last Updated: 19 Apr 2023 09:59 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
0
The DoInstead API cannot be used in scenarios that require the method call arguments to be captured and a specific return value to be provided.
Unplanned
Last Updated: 13 Apr 2023 08:40 by Ivo

The following code snippet causes a hang in the test execution while being debugged:

Mock.SetupStatic(typeof(TimeSpan), Behavior.CallOriginal, StaticConstructor.NonMocked);
Mock.Arrange(() => TimeSpan.FromSeconds(15)).Returns(TimeSpan.MinValue);

The issue can be temporary solved by disabling the DebugWindow via JustMock extension menu. 

Unplanned
Last Updated: 15 Mar 2023 06:42 by Quoc Tin

Hello

I generate a syntax tree which I will format with Formatter.Format() from the package Microsoft.CodeAnalysis.CSharp.Workspaces 4.4.0 and .NET 6. A test exists where the formatter is used but when the JustMock profiler is enabled an InvalidProgramException is thrown. When the profiler is disabled everything works fine. It fails on Windows and on Linux.

Exception

  Message: 
System.InvalidProgramException : Common Language Runtime detected an invalid program.

  Stack Trace: 
ContextIntervalTree`2.ctor(TIntrospector& introspector)
FormattingContext.ctor(AbstractFormatEngine engine, TokenStream tokenStream)
AbstractFormatEngine.CreateFormattingContext(TokenStream tokenStream, CancellationToken cancellationToken)
AbstractFormatEngine.Format(CancellationToken cancellationToken)
CSharpSyntaxFormatting.Format(SyntaxNode node, SyntaxFormattingOptions options, IEnumerable`1 formattingRules, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken)
AbstractSyntaxFormatting.GetFormattingResult(SyntaxNode node, IEnumerable`1 spans, SyntaxFormattingOptions options, IEnumerable`1 rules, CancellationToken cancellationToken)
Formatter.GetFormattingResult(SyntaxNode node, IEnumerable`1 spans, Workspace workspace, OptionSet options, IEnumerable`1 rules, CancellationToken cancellationToken)
Formatter.Format(SyntaxNode node, IEnumerable`1 spans, Workspace workspace, OptionSet options, IEnumerable`1 rules, CancellationToken cancellationToken)
Formatter.Format(SyntaxNode node, Workspace workspace, OptionSet options, CancellationToken cancellationToken)
UnitTest1.Test1() line 23

Reproduction

You can reproduce this by writing an unit test for that (I used xUnit):

        [Fact]
        public void Test1()
        {
            var classText = @"using System; namespace TestNameSpace.Orders { public class Order
                            {
                                public Guid Id { get; set; }
                            }
                        }";

            var syntaxTree = CSharpSyntaxTree.ParseText(classText);
            var workspace = new AdhocWorkspace();

            var formattedClassText = Formatter.Format(syntaxTree.GetRoot(), workspace).ToFullString();

            var expected = @"using System;
namespace TestNameSpace.Orders
{
    public class Order
    {
        public Guid Id { get; set; }
    }
}";
            Assert.Equal(expected, formattedClassText);
        }
    }

System Info

JustMock

See attachments. We do not use the free edition.

.NET

dotnet --info
.NET SDK:
 Version:   7.0.200
 Commit:    534117727b

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.200\

Host:
  Version:      7.0.3
  Architecture: x64
  Commit:       0a2bda10e8

.NET SDKs installed:
  6.0.406 [C:\Program Files\dotnet\sdk]
  7.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

 

I already posted a question but can't delete it anymore: InvalidProgramException thrown when formatting SyntaxNodes in JustMock | Telerik Forums
Unplanned
Last Updated: 25 Jan 2023 10:55 by Ivo

Considering the following simple test scenario:

public abstract class TestBase
{
    public static TestContext TestContext { get; set; }
}

[TestClass]
public class UnitTest1 : TestBase
{
    [ClassInitialize]
    public static void ClassInitlialize(TestContext ctx)
    {
        TestContext = ctx;
    }

    [TestMethod]
    public void TestMethod1()
    {

    }
}

[TestClass]
public class UnitTest2 : TestBase
{
    [ClassInitialize]
    public static void ClassInitlialize(TestContext ctx)
    {
        TestContext = ctx;
    }

    [TestMethod]
    public void TestMethod1()
    {

    }
}

Attempt to run the tests above with JustMock profiler enabled fails with System.InvalidProgramException. The issue is not reproducible with MSTest.TestFramework and MSTest.TestAdapter packages prior to 3.0.x.

 

Unplanned
Last Updated: 11 Jan 2023 11:08 by Ivo

The issue is demonstrated with the following sample:

[Theory]
[MemberData(nameof(GetMemberDataContext))]
public void ValidParameters_Success(int param1, int param2)
{
	// Arrange
	Mock.SetupStatic(typeof(MyClass), Behavior.Strict, StaticConstructor.Mocked);
        Mock.Arrange(() => MyClass.method1()).Returns(true);

        // Act
	IService service = new Service();
	bool result = service.method2();

	// Assert
	Assert.True(result);
	Mock.Assert(() => MyClass.method1(), Occurs.Once()); // <-- the test fails here because it reports that method invocation occurs twice
}

The issue in not observed if the code is modified in the following way, which indicates behavioral incinsistency:

[Theory]
[MemberData(nameof(GetMemberDataContext))]
public void ValidParameters_Success(int param1, int param2)
{
	// Arrange
	Mock.SetupStatic(typeof(MyClass), Behavior.Strict, StaticConstructor.Mocked);
        Mock.Arrange(() => MyClass.method1()).Returns(true).OccursOnce();

        // Act
	IService service = new Service();
	bool result = service.method2();

	// Assert
	Assert.True(result);
	Mock.Assert<MyClass>();
}
 

Unplanned
Last Updated: 03 Jan 2023 16:56 by ADMIN
Created by: Mihail
Comments: 2
Type: Feature Request
1
Consider the scenario where a class has a string field which is his main data. This class has defined an implicit cast operator to string. When that cast operator is executed the resulted string will contain the value from the class field.

Implement support for mocking of an operator such as the one described. 
Unplanned
Last Updated: 10 Nov 2022 09:40 by Ivo
Mocking of these methods could not be made due to compiler (CS8175) or runtime (System.InvalidProgramException: Cannot create boxed ByRef-like values) errors.
Unplanned
Last Updated: 04 Jul 2022 11:41 by Ivo
Created by: Ivo
Comments: 0
Type: Feature Request
1

The threading model of UI apps differs from the test host and this might become a source of issues like the following: System.InvalidOperationException: "The calling thread must be STA, because many UI components require this". The request is about extending JustMock with some helpers that can be used to solve this issue easily.

Unplanned
Last Updated: 18 Jan 2022 09:35 by ADMIN
A documentation article should be added that explains how to integrate JustMock to work within JetBrains Rider
Unplanned
Last Updated: 01 Dec 2021 14:06 by ADMIN
Created by: Ivo
Comments: 0
Type: Feature Request
1
Coverlet (https://github.com/coverlet-coverage/coverlet) is a cross-platform .NET code coverage tool, so the integration should be considered for all currently (and also potentially) supported platforms by JustMock.
Unplanned
Last Updated: 16 Nov 2021 10:04 by ADMIN
Adding JustMock to the Extensions section under Assemblies in the Add Reference dialog will make it easier for the developers to find where the required dll is located.
1 2 3