You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written a little plugin where the method "loadTestsFromFile" returns a list of "unitest.TestSuite" and not a list of "unittest.TestCase". This is not a problem for nose which launchs the test and prints the result, but the xunit "nosetest.xml" report remains empty... :(
Is there a way to have a xunit report which considers instances of unittest.TestSuite?
Thank you,
This is intended behavior. In any case where you are creating tests, then nose composes them into a normal nose test suite, which includes the hooks to call plugins like the xunit plugin. But to give users the option of disabling that, if nose gets an actual test suite, it doesn't pull that suite apart and generate a new one. The assumption is that if you are passing in a fully realized test suite, you may be trying to produce some kind of behavior that's different from nose's defaults, so nose leaves test suites alone. Is there a reason your plugin can't return or yield test cases instead of a suite?
In this kind of case I'd try using a test generator instead of a plugin.
You can easily yield a test function that runs custom setup/teardown around
each generated test.
Thank you for your answer. Actually, I have a set of folders which
contains three files "setup.sh/tests.xml/teardown.sh" (I try to convert
our old self-made framework to a nose plugin). The file "tests.xml"
contains several tests. Then, the "setup.sh/teardown.sh" have to be
executed once for all tests of the folder, and not around each test.
The idea I had was to create a TestCase for each test in "tests.xml", and
to encapsulate them into a TestSuite where I override the "run" method to
launch my "setup.sh/teardown.sh" scripts. It works well, but it's broke
the xunit plugin...
Another idea was to use "beforeDirectory" for "setup.sh" and
"afterDirectory" for "teardown.sh", but "afterDirectory" is launched before
the launch of the tests loaded by "loadTestsFromDir"...
Currently, I do not have a solution which cover xunit and my scripts :(
Thank for your help...
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/542#issuecomment-7894826.
Activity
jpellerin commentedon Aug 20, 2012
This is intended behavior. In any case where you are creating tests, then nose composes them into a normal nose test suite, which includes the hooks to call plugins like the xunit plugin. But to give users the option of disabling that, if nose gets an actual test suite, it doesn't pull that suite apart and generate a new one. The assumption is that if you are passing in a fully realized test suite, you may be trying to produce some kind of behavior that's different from nose's defaults, so nose leaves test suites alone. Is there a reason your plugin can't return or yield test cases instead of a suite?
jpellerin commentedon Aug 21, 2012
In this kind of case I'd try using a test generator instead of a plugin.
You can easily yield a test function that runs custom setup/teardown around
each generated test.
On Tue, Aug 21, 2012 at 4:31 AM, Laurent Mazuel notifications@github.comwrote:
lmazuel commentedon Aug 22, 2012
Thanks for your answer, I will consider this way too.