0

I'm trying to do Selenium webdriver test automation through C#. I wanted to basically understand how NUnit works. I've the following code in VS

namespace SeleniumCHash
    {
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using System;
    using NUnit.Framework;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    [TestFixture]
    public class StartUpClassCopy
    {

        [SetUp]
        public void Initialize() {
            Console.WriteLine("hi");
        }

        [Test]
        public void LoginCheckCopy()
        {
            Console.WriteLine("hiTest");
        }

        [TearDown]
        public void EndTest()
        {
            Console.WriteLine("hiTear");
        }


    }
}

When I execute this through Test Explorer, the following is the output.

[12/4/2018 7:12:46 AM Informational] ------ Discover test started ------
[12/4/2018 7:12:49 AM Warning] No test is available in C:\Users\XXXX\Source\Repos\SeleniumCHash\SeleniumCHash\SeleniumCHash.csproj. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/4/2018 7:12:49 AM Informational] ========== Discover test finished: 0 found (0:00:03.4464214) ==========
[12/4/2018 7:13:04 AM Informational] ------ Run test started ------
[12/4/2018 7:13:05 AM Informational] NUnit Adapter 3.11.2.0: Test execution started
[12/4/2018 7:13:05 AM Informational] Running selected tests in C:\Users\XXXX\Source\Repos\SeleniumCHash\SeleniumCHash\bin\Debug\SeleniumCHash.exe
[12/4/2018 7:13:06 AM Informational]    NUnit3TestExecutor converted 2 of 2 NUnit test cases
[12/4/2018 7:13:06 AM Informational] NUnit Adapter 3.11.2.0: Test execution complete
[12/4/2018 7:13:06 AM Informational] ========== Run test finished: 1 run (0:00:02.0547664) ==========

I'm actually expecting the console to display this in the console.

hi
hiTest
hiTear
ItsMeGokul
  • 403
  • 1
  • 5
  • 16
  • Possible duplicate of [replace Console.WriteLine in NUnit?](https://stackoverflow.com/questions/6833558/replace-console-writeline-in-nunit) – BWA Dec 04 '18 at 12:39

1 Answers1

1

The Visual Studio output window is not the console. :-) In fact, running under Test Explorer, there is no console available.

NUnit, however, captures output directed to the console and does its own thing with it, saving it as part of the test result. That result is made available to the runner as well, which can also do its own thing.

In the case of the NUnit 3 VS adapter, what it does is add the text output to the test result displayed in Test Explorer. It's visible in the IDE if you select the test that was run. Below the tree of tests, you'll see the result, including the text output.

Pang
  • 9,564
  • 146
  • 81
  • 122
Charlie
  • 12,928
  • 1
  • 27
  • 31