Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mide1234 opened this issue Jun 17, 2020 · 2 comments
Closed

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

mide1234 opened this issue Jun 17, 2020 · 2 comments

Comments

@mide1234
Copy link

mide1234 commented Jun 17, 2020

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

@mide1234
Copy link
Author

Also note that using the DataCollectionLogger is not much helpful as it offers only logging an error or a warning. In my case it is more about logging a progress. Anyway the logger does not emit the message immediately but it seems to be kept by some dotnet test buffer which is emited to the console at the very end of dotnet test command.

I believe it would be nice to have the option to print some message immediately..

@Evangelink Evangelink added needs-triage This item should be discussed in the next triage meeting. triaged and removed needs-triage This item should be discussed in the next triage meeting. labels Aug 1, 2022
@nohwnd
Copy link
Member

nohwnd commented Jul 9, 2024

This is by design.

@nohwnd nohwnd closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants