Completed
Last Updated: 17 Oct 2023 12:33 by ADMIN
Ivo
Created on: 01 Dec 2021 13:35
Type: Bug Report
0
Executing tests in specific order results in a failure

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.

 

1 comment
ADMIN
Tsvetko
Posted on: 17 Oct 2023 12:22

Hello,

The issue is fixed in R3 2023 (2023.3.1011.155).

Regards, Tsvetko Progress Telerik

A brand new JustMock course was just added to the Virtual Classroom - the free self-paced technical training portal that gets you up to speed with Telerik and Kendo UI products! Check it out at https://learn.telerik.com.