Skip to content

Custom Collector does not emit Console.WriteLine to console #2465

Closed
@mide1234

Description

@mide1234

Description

When running dotnet test with --collect CustomCollector Console.WriteLine is not emitted into the console. Is it intended by design or can it be considered as a bug?

Steps to reproduce

  1. Create a custom collector like the following:
    [DataCollectorFriendlyName("SampleDataCollector")]
    [DataCollectorTypeUri("my://sample/datacollector")]
    public class SampleDataCollector: DataCollector
    {
        public override void Initialize(
            System.Xml.XmlElement configurationElement,
            DataCollectionEvents events,
            DataCollectionSink dataSink,
            DataCollectionLogger logger,
            DataCollectionEnvironmentContext environmentContext)
        {
            events.TestCaseEnd += this.Events_TestCaseEnd;
        }

        private void Events_TestCaseEnd(object sender, TestCaseEndEventArgs e)
        {            
            Console.WriteLine("Hello world!");
        }
    }
  1. Place it in a new project (the assembly name must end with "collector")
  2. Reference this collector project in some test project
  3. in console run dotnet test TestProjectFolder --collect SampleDataCollector
  4. check there is no sign of "Hello world!" in the console

Expected behavior

Console.WriteLine is emitted to the console.

Actual behavior

Console.WriteLine is NOT emitted to the console.

Environment

Windows 10, netstandard2.0, netcore3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions