Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-287978: ReSharper test runner instantiates every attribute in a project, every time a test is run.

$
0
0
Reporter Ben Reich (breich) Ben Reich (breich)
Created Jan 25, 2012 2:22:41 AM
Updated Jan 25, 2012 2:22:41 AM
Priority Normal
Type Unspecified
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
I ran into the following issue running NUnit tests through the ReSharper test runner (R# 6.1.37, VS 2010, NUnit 2.5.10). I have some attribute, and some class marked with that attribute:

public class AttributeThatIsSlowToInstantiateAttribute : Attribute
{
	public AttributeThatIsSlowToInstantiateAttribute(string x)
	{
		Thread.Sleep(1000000);
	}
}
[AttributeThatIsSlowToInstantiate("C'est la vie!")]
public class SillyClass
{
	public SillyClass(string x)
	{
		Console.WriteLine("Shalom, olam!");
	}
}


In the same project, I have some NUnit test method:

[Test]
public void SillyTest()
{
	Assert.IsTrue(true);
}


Now, when I run the test method through the Resharper test runner, the constructor of AttributeThatIsSlowToInstantiateAttribute is called. I understand that in order to detect tests throughout the project, ReSharper must call GetCustomAttributes on the assembly, which in turn instantiates instances of the attributes in the project. However, if I have a subset of tests selected in the test runner GUI, I don't understand why this attribute must be instantiated. If I run specific tests from the NUnit console, for example, the attributes are not instantiated.

Viewing all articles
Browse latest Browse all 106942

Trending Articles