Cannot use TestContext as in MSTest

Bug #1184232 reported by PabloFacture
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
New
Undecided
Unassigned

Bug Description

I have migrated lots of tests from MSTest to NUnit but it turns out that there is no equivalent TestContext on the adapter and cannot send some informational messages to the test result window. These messages are important while creating the tests or running them manually (not on the build server).

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 1184232] [NEW] Cannot use TestContext as in MSTest

As a developer of NUnit, I am not at all familiar with MS Test and would
rather not take the time to learn about it in order to understand your
request. I do know that MS has something called TestContext, but it has no
relation to the NUnit TestContext, which was developed independently. I
don't know what features it has in MS Test.

Therefore, please descrive what you would like to be able to do in NUnit
and we will see if there is a way to do it already or if it's possible to
add it as a feature.

Tell us what you would like to be able to write in the test and what you
would like to have happen as a result.

On Sun, May 26, 2013 at 1:23 AM, PabloFacture
<email address hidden>wrote:

> Public bug reported:
>
> I have migrated lots of tests from MSTest to NUnit but it turns out that
> there is no equivalent TestContext on the adapter and cannot send some
> informational messages to the test result window. These messages are
> important while creating the tests or running them manually (not on the
> build server).
>
> ** Affects: nunit-vs-adapter
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https://bugs.launchpad.net/bugs/1184232
>
> Title:
> Cannot use TestContext as in MSTest
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunit-vs-adapter/+bug/1184232/+subscriptions
>

Revision history for this message
PabloFacture (pescobar-x) wrote :
Download full text (3.3 KiB)

Consider the following test (using MSTEST)
using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace POConsultores.CanBusMonitor.Common.Test
{
    [TestClass]
    public class TestContextTest     {
        // context is set by Test Environment automatically         public TestContext TestContext { get; set; }         [TestMethod]
        public void WriteToContext()
        {
            Random r = new Random();
            int i = r.Next();
            TestContext.WriteLine("Using value {0} for testing.", i);
            // test goes on             // ...         }
    }
}
Yes, TestContext is different than context in NUNit, it basically allows to write informational messages that are associated to the test results and visible within VStudio. See attached image to see output on VStudio.

Messages might or might not be useful on the final test run at the build server. However, they are very useful while writing tests.

Let me know if you need further information.

>________________________________
> From: Charlie Poole <email address hidden>
>To: <email address hidden>
>Sent: Saturday, May 25, 2013 7:01 PM
>Subject: Re: [Bug 1184232] [NEW] Cannot use TestContext as in MSTest
>
>
>As a developer of NUnit, I am not at all familiar with MS Test and would
>rather not take the time to learn about it in order to understand your
>request. I do know that MS has something called TestContext, but it has no
>relation to the NUnit TestContext, which was developed independently. I
>don't know what features it has in MS Test.
>
>Therefore, please descrive what you would like to be able to do in NUnit
>and we will see if there is a way to do it already or if it's possible to
>add it as a feature.
>
>
>Tell us what you would like to be able to write in the test and what you
>would like to have happen as a result.
>
>
>On Sun, May 26, 2013 at 1:23 AM, PabloFacture
><email address hidden>wrote:
>
>> Public bug reported:
>>
>> I have migrated lots of tests from MSTest to NUnit but it turns out that
>> there is no equivalent TestContext on the adapter and cannot send some
>> informational messages to the test result window. These messages are
>> important while creating the tests or running them manually (not on the
>> build server).
>>
>> ** Affects: nunit-vs-adapter
>>      Importance: Undecided
>>          Status: New
>>
>> --
>> You received this bug notification because you are subscribed to NUnit
>> Extended Testing Platform.
>> https://bugs.launchpad.net/bugs/1184232
>>
>> Title:
>>  Cannot use TestContext as in MSTest
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/nunit-vs-adapter/+bug/1184232/+subscriptions
>>
>
>--
>You received this bug notification because you are subscribed to the bug
>report.
>https://bugs.launchpad.net/bugs/1184232
>
>Title:
>  Cannot use TestContext as in MSTest
>
>Status in NUnit Test Adapter for Visual Studio:
>  New
>
>Bug description:
>  I have migrated lots of tests from MSTest to NUnit but it turns out
>  that there is no equivalent TestContext on the adapter and cannot send
>  some informational messages to the test result window. These messages
>  are...

Read more...

Revision history for this message
Charlie Poole (charlie.poole) wrote :

This is a change to NUnit itself rather than to the test adapter. Because it's a major change of interface, I have assigned it to the 3.0 project. There are already some rather vague plans to add this facility to TestContext but no formal request was written before now. We can use this request to specify the interface to be used.

For the present, the best workaround is to use Console.Write to output text that is displayed by the adapter in the Output window.

Charlie

affects: nunit-vs-adapter → nunit-3.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.