Bug: Running all tests in a folder fails when the folder contains an nunit SetUpFixture class

102 views
Skip to first unread message

Michael Ketting

unread,
Nov 2, 2011, 6:04:43 AM11/2/11
to testdri...@googlegroups.com
Hi!

I have the folowing setup:
+ Folder
++ SubFolder1
------- SetUpFixture1
------- TestFixture1
------- TestFixture2
++ SubFolder2
------- TestFixture3
------- TestFixture4

When I try to run the nunit tests in SubFolder1 using TestDriven.NET, I get the following error message: "You can't execute a namespace as an ad-hoc test."
When I run the tests in Folder or SubFolder2, everything works fine, so it appears that TD.NET has an issue with folders containing SetUpFixture classes.
Also, no problem exists with SetUpFixture classes in the project root, i.e. when running the tests on the entire project instead of a single namespace.

Regards, Michael

Jamie Cansdale

unread,
Nov 2, 2011, 8:30:35 AM11/2/11
to testdri...@googlegroups.com
Hi Michael,

This is a side effect of how TestDriven.Net executes its tests. Rather
than crawl the target assembly looking for tests, both the discovery
and execution of tests is delegated to the plugin test runners.
TestDriven.Net passes a test path to the test runner, rather that a
complete list of tests to be executed.

When a subfolder is targeted, TestDriven.Net looks at the first class
in each of the contained source files. If all of the classes are in
the same namespace, the test runner will attempt to execute all tests
in the target namespace. If the classes are in mixed namespaces, it
will attempt to execute the first class in each source as a separate
test run (which can be very slow).

To make this work, try to ensure that all of your test classes for a
given folder are in the same namespace. Also, try putting the test
class first in the source file followed by any utility classes you're
using.

I know this setup isn't ideal, but changing it as this stage would be
very tricky.

Regards,
Jamie.

--
http://www.testdriven.net
http://twitter.com/jcansdale
http://weblogs.asp.net/nunitaddin

> --
> You received this message because you are subscribed to the Google Groups
> "TestDriven.NET Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/testdrivenusers/-/u3-SUApXi-0J.
> To post to this group, send email to testdri...@googlegroups.com.
> To unsubscribe from this group, send email to
> testdrivenuse...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testdrivenusers?hl=en.
>

Michael Ketting

unread,
Nov 2, 2011, 9:24:25 AM11/2/11
to testdri...@googlegroups.com
Hi Jamie!
Thanks for the quick response!


> To make this work, try to ensure that all of your test classes for a
> given folder are in the same namespace. Also, try putting the test
> class first in the source file followed by any utility classes you're
> using.

Considering your explanation, my sample was probably illconceived. I also run into this problem when I have test fixtures before the setup fixture, alphabetically speaking. Each class is in an individual source file. And all classes belong to the same namespace. So, if I understood you correclty, it should work in those cases?

If needed, I could mock up a short sample project.

Regards, Michael
Reply all
Reply to author
Forward
0 new messages