TestContext.CurrentContext.Test.Properties does not work with TestCase is specified

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

Bug Description

Tried in v2.6 and v2.6.2 through default NUnit Gui runner
Any property attribute specified on the test method stops coming through as soon as it becomes a TestCase
See example below. Identical tests, one is [Test] , one is [TestCase]

[TestFixture]
    public class TestNUnitPropertiesIssue
    {
        [Test]
        [Property("prop1", "prop1value")]
        public void MyPropTest_ok()
        {
            foreach (string key in TestContext.CurrentContext.Test.Properties.Keys)
            {
                Console.WriteLine("{0}: {1}", key, TestContext.CurrentContext.Test.Properties[key]);
            }
            Assert.AreEqual("prop1value", TestContext.CurrentContext.Test.Properties["prop1"]);
        }

        [TestCase("1")]
        [Property("prop1", "prop1value")]
        public void MyPropTest_fail(string s)
        {
            foreach (string key in TestContext.CurrentContext.Test.Properties.Keys)
            {
                Console.WriteLine("{0}: {1}", key, TestContext.CurrentContext.Test.Properties[key]);
            }
            Assert.AreEqual("prop1value", TestContext.CurrentContext.Test.Properties["prop1"]);
        }

    }

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 1082039] [NEW] TestContext.CurrentContext.Test.Properties does not work with TestCase is specified

It's possible that some changes we made to TestMethod were not
reflected on test cases.

Charlie

On Thu, Nov 22, 2012 at 6:25 AM, Ken Ko <email address hidden> wrote:
> Public bug reported:
>
> Tried in v2.6 and v2.6.2 through default NUnit Gui runner
> Any property attribute specified on the test method stops coming through as soon as it becomes a TestCase
> See example below. Identical tests, one is [Test] , one is [TestCase]
>
>
> [TestFixture]
> public class TestNUnitPropertiesIssue
> {
> [Test]
> [Property("prop1", "prop1value")]
> public void MyPropTest_ok()
> {
> foreach (string key in TestContext.CurrentContext.Test.Properties.Keys)
> {
> Console.WriteLine("{0}: {1}", key, TestContext.CurrentContext.Test.Properties[key]);
> }
> Assert.AreEqual("prop1value", TestContext.CurrentContext.Test.Properties["prop1"]);
> }
>
> [TestCase("1")]
> [Property("prop1", "prop1value")]
> public void MyPropTest_fail(string s)
> {
> foreach (string key in TestContext.CurrentContext.Test.Properties.Keys)
> {
> Console.WriteLine("{0}: {1}", key, TestContext.CurrentContext.Test.Properties[key]);
> }
> Assert.AreEqual("prop1value", TestContext.CurrentContext.Test.Properties["prop1"]);
> }
>
> }
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https://bugs.launchpad.net/bugs/1082039
>
> Title:
> TestContext.CurrentContext.Test.Properties does not work with TestCase
> is specified
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/1082039/+subscriptions

Revision history for this message
Simone Busoli (simone.busoli) wrote :

Hi Ken, can you tell what was the latest version where it used to work?

Revision history for this message
Ken Ko (fuzziman) wrote : Re: [Bug 1082039] Re: TestContext.CurrentContext.Test.Properties does not work with TestCase is specified

Thanks for the quick response. I only started using the TestContext in v2.6

Just tried in 2.5.10 and got the same fail.

On 23/11/2012, at 5:35 AM, Simone Busoli <email address hidden> wrote:

> Hi Ken, can you tell what was the latest version where it used to work?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1082039
>
> Title:
> TestContext.CurrentContext.Test.Properties does not work with TestCase
> is specified
>
> Status in NUnit V2 Test Framework:
> New
>
> Bug description:
> Tried in v2.6 and v2.6.2 through default NUnit Gui runner
> Any property attribute specified on the test method stops coming through as soon as it becomes a TestCase
> See example below. Identical tests, one is [Test] , one is [TestCase]
>
>
> [TestFixture]
> public class TestNUnitPropertiesIssue
> {
> [Test]
> [Property("prop1", "prop1value")]
> public void MyPropTest_ok()
> {
> foreach (string key in TestContext.CurrentContext.Test.Properties.Keys)
> {
> Console.WriteLine("{0}: {1}", key, TestContext.CurrentContext.Test.Properties[key]);
> }
> Assert.AreEqual("prop1value", TestContext.CurrentContext.Test.Properties["prop1"]);
> }
>
> [TestCase("1")]
> [Property("prop1", "prop1value")]
> public void MyPropTest_fail(string s)
> {
> foreach (string key in TestContext.CurrentContext.Test.Properties.Keys)
> {
> Console.WriteLine("{0}: {1}", key, TestContext.CurrentContext.Test.Properties[key]);
> }
> Assert.AreEqual("prop1value", TestContext.CurrentContext.Test.Properties["prop1"]);
> }
>
> }
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/1082039/+subscriptions

Revision history for this message
Simone Busoli (simone.busoli) wrote : Re: [Nunit-core] [Bug 1082039] Re: TestContext.CurrentContext.Test.Properties does not work with TestCase is specified
Download full text (4.1 KiB)

So it's not unlikely that it never worked

On Thu, Nov 22, 2012 at 9:52 PM, Ken Ko <email address hidden> wrote:

> Thanks for the quick response. I only started using the TestContext in
> v2.6
>
> Just tried in 2.5.10 and got the same fail.
>
>
> On 23/11/2012, at 5:35 AM, Simone Busoli <email address hidden>
> wrote:
>
> > Hi Ken, can you tell what was the latest version where it used to work?
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1082039
> >
> > Title:
> > TestContext.CurrentContext.Test.Properties does not work with TestCase
> > is specified
> >
> > Status in NUnit V2 Test Framework:
> > New
> >
> > Bug description:
> > Tried in v2.6 and v2.6.2 through default NUnit Gui runner
> > Any property attribute specified on the test method stops coming through
> as soon as it becomes a TestCase
> > See example below. Identical tests, one is [Test] , one is [TestCase]
> >
> >
> > [TestFixture]
> > public class TestNUnitPropertiesIssue
> > {
> > [Test]
> > [Property("prop1", "prop1value")]
> > public void MyPropTest_ok()
> > {
> > foreach (string key in
> TestContext.CurrentContext.Test.Properties.Keys)
> > {
> > Console.WriteLine("{0}: {1}", key,
> TestContext.CurrentContext.Test.Properties[key]);
> > }
> > Assert.AreEqual("prop1value",
> TestContext.CurrentContext.Test.Properties["prop1"]);
> > }
> >
> > [TestCase("1")]
> > [Property("prop1", "prop1value")]
> > public void MyPropTest_fail(string s)
> > {
> > foreach (string key in
> TestContext.CurrentContext.Test.Properties.Keys)
> > {
> > Console.WriteLine("{0}: {1}", key,
> TestContext.CurrentContext.Test.Properties[key]);
> > }
> > Assert.AreEqual("prop1value",
> TestContext.CurrentContext.Test.Properties["prop1"]);
> > }
> >
> > }
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/nunitv2/+bug/1082039/+subscriptions
>
> --
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
> https://bugs.launchpad.net/bugs/1082039
>
> Title:
> TestContext.CurrentContext.Test.Properties does not work with TestCase
> is specified
>
> Status in NUnit V2 Test Framework:
> New
>
> Bug description:
> Tried in v2.6 and v2.6.2 through default NUnit Gui runner
> Any property attribute specified on the test method stops coming through
> as soon as it becomes a TestCase
> See example below. Identical tests, one is [Test] , one is [TestCase]
>
>
> [TestFixture]
> public class TestNUnitPropertiesIssue
> {
> [Test]
> [Property("prop1", "prop1value")]
> public void MyPropTest_ok()
> {
> foreach (string key in
> TestContext.CurrentContext.Test.Properties.Keys)
> {
> Console.WriteLine("{0}: {1}", key,
> TestContext.CurrentContext.Test.Properties[key]);
> }
> Asser...

Read more...

Revision history for this message
Charlie Poole (charlie.poole) wrote :
Download full text (4.8 KiB)

Looking at NUnit's tests of TestContext, I see there are only simple
[Test] tests, no TestCases. So that's a possibility.

On Thu, Nov 22, 2012 at 2:08 PM, Simone Busoli
<email address hidden> wrote:
> So it's not unlikely that it never worked
>
>
> On Thu, Nov 22, 2012 at 9:52 PM, Ken Ko <email address hidden> wrote:
>
>> Thanks for the quick response. I only started using the TestContext in
>> v2.6
>>
>> Just tried in 2.5.10 and got the same fail.
>>
>>
>> On 23/11/2012, at 5:35 AM, Simone Busoli <email address hidden>
>> wrote:
>>
>> > Hi Ken, can you tell what was the latest version where it used to work?
>> >
>> > --
>> > You received this bug notification because you are subscribed to the bug
>> > report.
>> > https://bugs.launchpad.net/bugs/1082039
>> >
>> > Title:
>> > TestContext.CurrentContext.Test.Properties does not work with TestCase
>> > is specified
>> >
>> > Status in NUnit V2 Test Framework:
>> > New
>> >
>> > Bug description:
>> > Tried in v2.6 and v2.6.2 through default NUnit Gui runner
>> > Any property attribute specified on the test method stops coming through
>> as soon as it becomes a TestCase
>> > See example below. Identical tests, one is [Test] , one is [TestCase]
>> >
>> >
>> > [TestFixture]
>> > public class TestNUnitPropertiesIssue
>> > {
>> > [Test]
>> > [Property("prop1", "prop1value")]
>> > public void MyPropTest_ok()
>> > {
>> > foreach (string key in
>> TestContext.CurrentContext.Test.Properties.Keys)
>> > {
>> > Console.WriteLine("{0}: {1}", key,
>> TestContext.CurrentContext.Test.Properties[key]);
>> > }
>> > Assert.AreEqual("prop1value",
>> TestContext.CurrentContext.Test.Properties["prop1"]);
>> > }
>> >
>> > [TestCase("1")]
>> > [Property("prop1", "prop1value")]
>> > public void MyPropTest_fail(string s)
>> > {
>> > foreach (string key in
>> TestContext.CurrentContext.Test.Properties.Keys)
>> > {
>> > Console.WriteLine("{0}: {1}", key,
>> TestContext.CurrentContext.Test.Properties[key]);
>> > }
>> > Assert.AreEqual("prop1value",
>> TestContext.CurrentContext.Test.Properties["prop1"]);
>> > }
>> >
>> > }
>> >
>> > To manage notifications about this bug go to:
>> > https://bugs.launchpad.net/nunitv2/+bug/1082039/+subscriptions
>>
>> --
>> You received this bug notification because you are a member of NUnit
>> Developers, which is subscribed to NUnit V2.
>> https://bugs.launchpad.net/bugs/1082039
>>
>> Title:
>> TestContext.CurrentContext.Test.Properties does not work with TestCase
>> is specified
>>
>> Status in NUnit V2 Test Framework:
>> New
>>
>> Bug description:
>> Tried in v2.6 and v2.6.2 through default NUnit Gui runner
>> Any property attribute specified on the test method stops coming through
>> as soon as it becomes a TestCase
>> See example below. Identical tests, one is [Test] , one is [TestCase]
>>
>>
>> [TestFixture]
>> public class TestNUnitPropertiesIssue
>> {
>> [Test]
>> [Property("prop1", "prop1value")]
>> ...

Read more...

affects: nunitv2 → 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.