Skip to content

Running tests with ITestAction attributes leaks memory #3858

Closed
@MatteS75

Description

@MatteS75

Running this example:


    [SomeTestAttr]
    [TestFixtureSource(nameof(FixtureArgs))]
    public class Tests1
    {
        private static object[] FixtureArgs = Enumerable.Range(0, 100)
            .Select(a => new object[] {$"a{a:000}"})
            .ToArray();

        public Tests1(string arg)
        {
        }

        [Test]
        public void Test1([Range(0, 10)] int x)
        {
            Thread.Sleep(100);
            Assert.Pass();
        }
    }

    public class SomeTestAttrAttribute : Attribute, ITestAction
    {
        private object _data = Enumerable.Range(0, 1000000).ToArray();
        
        public void BeforeTest(ITest test)
        {
        }

        public void AfterTest(ITest test)
        {
        }

        public ActionTargets Targets { get; }
    }
    

From what we can see new attributes are created for each fixture, but never released.

This example is using TestFixtureSource to create many fixtures, but from what we can see the behavior is the same with multiple fixture classes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions