Comment 2 for bug 1184232

Revision history for this message
PabloFacture (pescobar-x) wrote : Re: [Bug 1184232] [NEW] Cannot use TestContext as in MSTest

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 important while creating the tests or running them manually (not
>  on the build server).
>
>To manage notifications about this bug go to:
>https://bugs.launchpad.net/nunit-vs-adapter/+bug/1184232/+subscriptions
>
>
>