display test name along with test arguments

234 views
Skip to first unread message

srikanth d

unread,
Mar 22, 2017, 2:44:49 AM3/22/17
to NUnit-Discuss
Hi,

I am working on a c# environment and use Nunit to run tests.
The problem i see is that when logs are generated, it is difficult to distinguish which logs came from which test.

So, i was wondering if nunit has support for any of the below features.

1. Display name of test currently being run
By this i mean the similar way we see in the nunit gui window. For example, if we use Testcase with multiple arguments, or loop variables, there should be some marker in the logs which indicates that this test/testcase was run with these arguments
I want to be able to display this at the beginning. Typically in the setup function. If not possible, atleast in the actual testcase.
So, is there a provision for that?
If so, can this also be extended to parameterized tests?

2. If the above is not possible, can we somehow change the log names with the test names?

Your help is really appreciated.

Thanks,
Srikanth

Charlie Poole

unread,
Mar 22, 2017, 1:39:10 PM3/22/17
to NUnit-Discuss
Hi Srikanth,

I'm sorry, but there are several things in NUnit you might mean by
"logs." Could you please be more specific? Also, how are you running
your tests (what runner) and what version of NUnit (framework) are you
using?

Charlie
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.
> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

srikanth d

unread,
Mar 23, 2017, 8:38:24 AM3/23/17
to nunit-...@googlegroups.com
Hi Charlie,

I am not from a software background. So, pardon my ignorance.
As per your questions, i tried to answer below.

Q) I'm sorry, but there are several things in NUnit you might mean by

"logs." Could you please be more specific?
A)We use log4net to display the output during test execution. The log is specific to the test being run. Nothing else.

Q) Also, how are you running your tests (what runner)
A) i dont understand what you mean by runner. I believe the nunit is the runner. We simply load the dll file generated via visual studio after c# compilation and invoke nunit gui. Sometimes run it in batch mode using batch script.

Q) Nunit version
A) 2.5.9.10348

I think i got the solution for the first problem of getting test name from inside the testcase.
NUnit.Framework.TestContext.CurrentContext.Test
.FullName 

For the second issue, i will need help.
We use log4net for test results display. But when we run the whole test suite, we get all logs into one single file or in sets of single file extensions based on file size and some log4net settings.

I want to create one log file for each Test. If possible, for each Testcase combination.
Any help on this is greatly appreciated.

Thanks,
Srikanth











> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "NUnit-Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nunit-discuss+unsubscribe@googlegroups.com.

Charlie Poole

unread,
Mar 23, 2017, 1:00:08 PM3/23/17
to NUnit-Discuss
Hi Srikanth,

Ok, that clarifies things a bit.

As you know, log4net is a piece of software that has nothing to do
with NUnit. Old versions (V2) of NUnit captured log4net output and
displayed it in the Gui but with NUnit 3 we decided to stop trying to
support any logging software specially. Naturally, your own software
and tests can use log4net - in fact, that's one reason NUnit has
stopped interfering with its function.

A runner - in this context - is a piece of software that knows how to
run tests. It sounds as if you use the nunit gui as your runner. Other
runners include the nunit console runner, the nunit VS adapter and
various third-party software packages like test-driven and resharper.
We have to ask you what runner you use because it's almost always
relevant.

So... your first question is about how to get the full test name to
send to log4net. Your own answer - using TestContext - is correct. :-)

Regarding how to open and close different files using log4net, you
would have to contact the developers of that program. I suspect that
it will require a fair bit of code in each test. That makes sense
because you are trying to use log4net as a reporting program rather
than as a logger, which is what it is designed to be.

Charlie
>> > email to nunit-discus...@googlegroups.com.
>> > To post to this group, send email to nunit-...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/nunit-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "NUnit-Discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> nunit-discus...@googlegroups.com.
>> To post to this group, send email to nunit-...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/nunit-discuss.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.

srikanth d

unread,
Mar 23, 2017, 2:22:42 PM3/23/17
to nunit-...@googlegroups.com
Ok that makes sense. Thanks for that charlie. 
Can i trouble you with one more question?
I want to make custom modifications to 
How i run my tests. Basically i have few tests which configure my program( say testconf*) and few which test it's behavior(testbehavior*). I want to make combinations of these. So will i need a seperate runner as u have explained to achieve this? If not how can nunit help here? I tried using nunit console. The problem is getting the test list. Is there a way to get this list in the dll?


If a seperate runner is needed , any recommendations? 

Thanks,
Srikanth







>> > To post to this group, send email to nunit-...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/nunit-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "NUnit-Discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>> To post to this group, send email to nunit-...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/nunit-discuss.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "NUnit-Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nunit-discuss+unsubscribe@googlegroups.com.

Charlie Poole

unread,
Mar 23, 2017, 7:56:53 PM3/23/17
to NUnit-Discuss
Since you are using an old version of NUnit, your options are a bit
more limited than with the current version. There are two approaches
you can try.

1. Don't consider your configuration as a "test" but as setup. Use the
TestFixtureSetUp attribute to configure your program before any of the
tests in your fixture run. If necessary use TestFixtureTearDown to
"unconfigure" or clean up.

2. If you need to create combinations where the same tests are run
using different configurations, place the test methods in an abstract
base class, which is inherited by your "real" test classes. The
TestFixtureSetUp that does the configuration should be in the derived
class.

Charlie

On Thu, Mar 23, 2017 at 11:22 AM, srikanth d
>> >> > email to nunit-discus...@googlegroups.com.
>> >> > To post to this group, send email to nunit-...@googlegroups.com.
>> >> > Visit this group at https://groups.google.com/group/nunit-discuss.
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >>
>> >> --
>> >> You received this message because you are subscribed to a topic in the
>> >> Google Groups "NUnit-Discuss" group.
>> >> To unsubscribe from this topic, visit
>> >>
>> >> https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
>> >> To unsubscribe from this group and all its topics, send an email to
>> >> nunit-discus...@googlegroups.com.
>> >> To post to this group, send email to nunit-...@googlegroups.com.
>> >> Visit this group at https://groups.google.com/group/nunit-discuss.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "NUnit-Discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to nunit-discus...@googlegroups.com.
>> > To post to this group, send email to nunit-...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/nunit-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "NUnit-Discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> nunit-discus...@googlegroups.com.
>> To post to this group, send email to nunit-...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/nunit-discuss.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.

srikanth d

unread,
Mar 23, 2017, 11:37:22 PM3/23/17
to nunit-...@googlegroups.com
Ok, that sounds good charlie. I will give it a try. Thankyou very much for your help.


>> >> > To post to this group, send email to nunit-...@googlegroups.com.
>> >> > Visit this group at https://groups.google.com/group/nunit-discuss.
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >>
>> >> --
>> >> You received this message because you are subscribed to a topic in the
>> >> Google Groups "NUnit-Discuss" group.
>> >> To unsubscribe from this topic, visit
>> >>
>> >> https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
>> >> To unsubscribe from this group and all its topics, send an email to

>> >> To post to this group, send email to nunit-...@googlegroups.com.
>> >> Visit this group at https://groups.google.com/group/nunit-discuss.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "NUnit-Discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an

>> > To post to this group, send email to nunit-...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/nunit-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "NUnit-Discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>> To post to this group, send email to nunit-...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/nunit-discuss.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "NUnit-Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nunit-discuss/LsIu2ZnZcDo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nunit-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages