Include inner class test cases when running enclosing test fixture

33 views
Skip to first unread message

Kenneth Xu

unread,
Sep 10, 2009, 11:02:06 AM9/10/09
to NUnit-Discuss
Hi,

Will NUnit execute the test fixture defined as inner class when I test
run the enclosing test fixture?

The answer is, it depends (as of version 2.5.2). In most of cases it
won't, but if the enclosing test fixture is a generic type, it will.
And my wish is it will always runs the tests in inner classes. i.e.
Logically, from the language perspective, inner classes are members of
the enclosing class. And that is the only reason I use inner test
fixture for.

That also can be a potential solution for aggregating reusable test
fixtures.

I have example and more detailed explanation here (sorry too long to
write in the email):
http://kennethxu.blogspot.com/2009/09/how-nunit-handles-test-fixture-as-inner.html

Any thoughts?

Thanks,
Kenneth

Charlie Poole

unread,
Sep 10, 2009, 11:53:07 AM9/10/09
to nunit-...@googlegroups.com
Ah ha! Since I wrote the code for the run option, I can tell you
why the results vary:

1) I never even considered nested classes as a use case
2) We didn't have generics at the time.

So the results you are seeing with cases B and C are
actually bugs - at least in terms of what the option
was intended to do.

That said, I agree with your analysis. It makes more
sense to treat a nested class as a member of the class
in question. I would not want to do this piecemeal,
however. I think we should treat things consistently
for the console and Gui runners.

So far we have:
* Naming of tests in the console test case labels
* Naming of tests in the Gui
* Hierarchical display of inner classes in the Gui
* Use with the /run option
* By extension, use with the /fixture option

Any thing else?

Charlie
that I never even considered the case of nested classes, so
the results you see with generics are accidents of the
implementation... as follows...

If the value you pass to the run option is the name of
a type, then that type is used as a fixture. If not, it
is assumed to be a namespace and we look for all classes
whose fullname has that value as a prefix.

Kenneth Xu

unread,
Sep 10, 2009, 1:44:53 PM9/10/09
to NUnit-Discuss
Hi Charlie,

> So far we have:
>  * Naming of tests in the console test case labels
>  * Naming of tests in the Gui
>  * Hierarchical display of inner classes in the Gui
>  * Use with the /run option
>  * By extension, use with the /fixture option
>
> Any thing else?

Your list looks good to me. I cannot comment on /fixture as I never
used/thought about it.
BTW I have created issues on Launchpad for item 1 and 2.

Cheers,
Kenneth
Reply all
Reply to author
Forward
0 new messages