Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.

Asked by Tomasz Chmielewski

Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.

For following test method attributes:

        [Test, Property("Id", 960), Combinatorial, Description("Try to log without user and password provided.")]
        public void ShouldTestLoginCombinatorial(
            [ValueSource("Logins")] string login,
            [ValueSource("Passwords")] string password)
        {
            ...
         }

I expect to be possible to get the Id property in the TearDown method like this (only once after all tests are done and with the result of tests pass when all resulting from combinatorial pass or fail when any test fail):

            Console.WriteLine(TestContext.CurrentContext.Test.Properties["Id"].ToString());

Insead the only property avaibile there is for _CATEGORIES key form TestContext.CurrentContext.Test.Properties dictionary.

Any chance to workaround it?

Is that a well known bug?

Is it allready reported in bug list?

Your sinclery,
Tomasz Chmielewski

Question information

Language:
English Edit question
Status:
Answered
For:
NUnit V2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Charlie Poole (charlie.poole) said :
#1

See the explanation in the comments for this bug:
https://bugs.launchpad.net/nunit-3.0/+bug/1208356

In summary, the attribute is applied to the method and creates a
property on the test suite, which contains each individual test case
generated, not on the individual test cases.

As explained in the bug, there is no way NUnit can determine which
properties might reasonably apply to the individual cases and which
might not, without some help from the user.

We'll work on this for NUnit 3.0.

Charlie

On Mon, Aug 26, 2013 at 8:06 AM, Tomasz Chmielewski
<email address hidden> wrote:
> New question #234643 on NUnit V2:
> https://answers.launchpad.net/nunitv2/+question/234643
>
> Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.
>
> For following test method attributes:
>
> [Test, Property("Id", 960), Combinatorial, Description("Try to log without user and password provided.")]
> public void ShouldTestLoginCombinatorial(
> [ValueSource("Logins")] string login,
> [ValueSource("Passwords")] string password)
> {
> ...
> }
>
> I expect to be possible to get the Id property in the TearDown method like:
>
> Console.WriteLine(TestContext.CurrentContext.Test.Properties["Id"].ToString());
>
>
> Insead the only property avaibile there is for _CATEGORIES key form TestContext.CurrentContext.Test.Properties dictionary.
>
>
> Any chance to workaround it?
>
> Is that a well known bug?
>
> Is it allready reported in bug list?
>
>
> Your sinclery,
> Tomasz Chmielewski
>
> --
> You received this question notification because you are an answer
> contact for NUnit V2.

Revision history for this message
Tomasz Chmielewski (tomasz-chmielewski) said :
#2

Thanks for prompt answer.

I have few additional questions:

- when do you plan to release NUnit V3?
- is it possible to work around the "problem" extending NUnit with Test Decorator addin?
- if above is true > perhaps you know if Jenkins' NUnit plugin support using addins? (can't find the answer anywhere on the net)

--

Thanks/Pozdrawiam,
Tomek

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Charlie Poole
Sent: 26 sierpnia 2013 23:21
To: Chmielewski Tomasz - tchmie
Subject: Re: [Question #234643]: Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.

Your question #234643 on NUnit V2 changed:
https://answers.launchpad.net/nunitv2/+question/234643

    Status: Open => Answered

Charlie Poole proposed the following answer:
See the explanation in the comments for this bug:
https://bugs.launchpad.net/nunit-3.0/+bug/1208356

In summary, the attribute is applied to the method and creates a property on the test suite, which contains each individual test case generated, not on the individual test cases.

As explained in the bug, there is no way NUnit can determine which properties might reasonably apply to the individual cases and which might not, without some help from the user.

We'll work on this for NUnit 3.0.

Charlie

On Mon, Aug 26, 2013 at 8:06 AM, Tomasz Chmielewski <email address hidden> wrote:
> New question #234643 on NUnit V2:
> https://answers.launchpad.net/nunitv2/+question/234643
>
> Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.
>
> For following test method attributes:
>
> [Test, Property("Id", 960), Combinatorial, Description("Try to log without user and password provided.")]
> public void ShouldTestLoginCombinatorial(
> [ValueSource("Logins")] string login,
> [ValueSource("Passwords")] string password)
> {
> ...
> }
>
> I expect to be possible to get the Id property in the TearDown method like:
>
>
> Console.WriteLine(TestContext.CurrentContext.Test.Properties["Id"].ToS
> tring());
>
>
> Insead the only property avaibile there is for _CATEGORIES key form TestContext.CurrentContext.Test.Properties dictionary.
>
>
> Any chance to workaround it?
>
> Is that a well known bug?
>
> Is it allready reported in bug list?
>
>
> Your sinclery,
> Tomasz Chmielewski
>
> --
> You received this question notification because you are an answer
> contact for NUnit V2.

--
If this answers your question, please go to the following page to let us know that it is solved:
https://answers.launchpad.net/nunitv2/+question/234643/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the following page to enter your feedback:
https://answers.launchpad.net/nunitv2/+question/234643

You received this question notification because you asked the question.
***************************************************************************
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be legally
privileged.

If the reader of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank You.
****************************************************************************

Revision history for this message
Charlie Poole (charlie.poole) said :
#3

NUnit 3.0 should be released before the end of the year. Right now
there are only pre-alpha builds.

A TestDecorator is a possibility. You would have to access the
containing suite and copy the appropriate properties to the property
bag for the current test. You'd want to only copy properties you know
about, not every property you find. Bear in mind that TestDecorator
won't exist in NUnit 3.0 as it's being replaced by a simpler
attribute-based approach.

An even simpler approach would be to use reflection to find properties
on the method. You could put that into a function to be called by your
tests.

It's also possible that you can figure out a way to do this with
ActionAttributes.

Charlie

On Tue, Aug 27, 2013 at 12:56 AM, Tomasz Chmielewski
<email address hidden> wrote:
> Question #234643 on NUnit V2 changed:
> https://answers.launchpad.net/nunitv2/+question/234643
>
> Status: Answered => Open
>
> Tomasz Chmielewski is still having a problem:
> Thanks for prompt answer.
>
> I have few additional questions:
>
> - when do you plan to release NUnit V3?
> - is it possible to work around the "problem" extending NUnit with Test Decorator addin?
> - if above is true > perhaps you know if Jenkins' NUnit plugin support using addins? (can't find the answer anywhere on the net)
>
> --
>
> Thanks/Pozdrawiam,
> Tomek
>
>
> -----Original Message-----
> From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Charlie Poole
> Sent: 26 sierpnia 2013 23:21
> To: Chmielewski Tomasz - tchmie
> Subject: Re: [Question #234643]: Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.
>
> Your question #234643 on NUnit V2 changed:
> https://answers.launchpad.net/nunitv2/+question/234643
>
> Status: Open => Answered
>
> Charlie Poole proposed the following answer:
> See the explanation in the comments for this bug:
> https://bugs.launchpad.net/nunit-3.0/+bug/1208356
>
> In summary, the attribute is applied to the method and creates a
> property on the test suite, which contains each individual test case
> generated, not on the individual test cases.
>
> As explained in the bug, there is no way NUnit can determine which
> properties might reasonably apply to the individual cases and which
> might not, without some help from the user.
>
> We'll work on this for NUnit 3.0.
>
> Charlie
>
>
> On Mon, Aug 26, 2013 at 8:06 AM, Tomasz Chmielewski <email address hidden> wrote:
>> New question #234643 on NUnit V2:
>> https://answers.launchpad.net/nunitv2/+question/234643
>>
>> Property attribute is missing for TestCase/TestCaseSource/ValueSouerce attribute based tests.
>>
>> For following test method attributes:
>>
>> [Test, Property("Id", 960), Combinatorial, Description("Try to log without user and password provided.")]
>> public void ShouldTestLoginCombinatorial(
>> [ValueSource("Logins")] string login,
>> [ValueSource("Passwords")] string password)
>> {
>> ...
>> }
>>
>> I expect to be possible to get the Id property in the TearDown method like:
>>
>>
>> Console.WriteLine(TestContext.CurrentContext.Test.Properties["Id"].ToS
>> tring());
>>
>>
>> Insead the only property avaibile there is for _CATEGORIES key form TestContext.CurrentContext.Test.Properties dictionary.
>>
>>
>> Any chance to workaround it?
>>
>> Is that a well known bug?
>>
>> Is it allready reported in bug list?
>>
>>
>> Your sinclery,
>> Tomasz Chmielewski
>>
>> --
>> You received this question notification because you are an answer
>> contact for NUnit V2.
>
> --
> If this answers your question, please go to the following page to let us know that it is solved:
> https://answers.launchpad.net/nunitv2/+question/234643/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the following page to enter your feedback:
> https://answers.launchpad.net/nunitv2/+question/234643
>
> You received this question notification because you asked the question.
> ***************************************************************************
> The information contained in this communication is confidential, is
> intended only for the use of the recipient named above, and may be legally
> privileged.
>
> If the reader of this message is not the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited.
>
> If you have received this communication in error, please resend this
> communication to the sender and delete the original message or any copy
> of it from your computer system.
>
> Thank You.
> ****************************************************************************
>
> --
> You received this question notification because you are an answer
> contact for NUnit V2.

Can you help with this problem?

Provide an answer of your own, or ask Tomasz Chmielewski for more information if necessary.

To post a message you must log in.