question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing console output when use SetUp method

See original GitHub issue

Setup:

  • NUnit 3.13.3
  • NUnit3TeasAdapter 4.2.1
  • VS2022
  • .NET5

Wrote single test for module that runs with multiple threads and writes logs by NLog. Runed this test, all necessary logs are present in test journal. Then I splited it to OneTimeSetUp and Test to write another test with similar logic. After that test journal contains only logs writed by Test method thread. Missing output from HostRepresentative_CorrectionReady and other threads that triggers by ValueChanged method.

    [TestFixture]
    class TimingTests
    {
        HostRepresentative hostRepresentative;
        PathProcessor pathProcessor;
        HWPropEngine.ConfigProps configProps;
        AutoResetEvent readyEvent = new AutoResetEvent(false);
        List<Span> sweeplist;

        [OneTimeSetUp]
        public void Setup()
        {
            hostRepresentative = HostRepresentative.getInstance();
            pathProcessor = PathProcessor.getInstance();
            configProps = new HWPropEngine.ConfigProps();

            // Some Init stuff

            hostRepresentative.CorrectionReady += HostRepresentative_CorrectionReady;
        }

        private void HostRepresentative_CorrectionReady(object sender, Dictionary<string, string> e)
        {
            foreach (var item in e)
            {
                Console.WriteLine($"{item.Key} = {item.Value}");
            }

            readyEvent.Set();
        }

        [Test, MaxTime(150)]
        public void FullTimingTestSmallSweep()
        {
            readyEvent.Reset();

            configProps.CF.SetValue(100e6);
            hostRepresentative.ValueChanged(configProps.CF.HardwareProperty);

            readyEvent.WaitOne();
            sweeplist = pathProcessor.CreateSweepList();
        }
    }

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
OsirisTerjecommented, Jul 10, 2023

@RedHeadIvan Hi! I had a new look at this (sorry for the delay though) , and the difference between the two ways of running is that with DoubleStage enabled then the preprocessor.Init() is called in the OneTimeSetup method, without it is connected to the Test itself. The OneTimeSetup happens before any tests are run, and we don’t actually capture the output from that part. If you enable the Dump feature you can actually see where the output goesfrom NUnit, so NUnit captures this. The problem is with the Test Explorer.

The reason for this is that we don’t have any suitable place to go - in the Test Explorer - with this output. We can send the output to the Test Explorer - which is responsible for displaying this - for each test case, but there is no sink for something like OneTimeSetup.

We do have some other issues related to the same, so this is a duplicate of those. (E.g. nunit/nunit3-vs-adapter#266, #503 and nunit/nunit#4314).
We’ll have another look for a fix on this.

Thank you for reporting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write to Console.Out during execution of an MSTest ...
The Console output is not appearing is because the backend code is not running in the context of the test. You're probably better...
Read more >
Unit Test Runner does not show console output
I'm experiencing the same issue, xunit, serilog configured to print to console. When debugging, there is Debug->Console tab that show the logs.
Read more >
Configure the Console output | Filebeat Reference [8.9]
The Console output should be used only for debugging issues as it can produce a large amount of logging data. To use this...
Read more >
Capturing Output
When xUnit.net v2 shipped with parallelization turned on by default, this output capture mechanism was no longer appropriate; it is impossible to know...
Read more >
C# console app template generates top-level statements
NET 6+ project template for C# console apps uses top-level statements. Understand what changed and how to use existing learning materials ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found