← Back to DAGDA | Support | Source: https://github.com/nose-devs/nose/issues/542
Skip to content

xunit and unittest.TestSuite #542

Closed
Closed

Description

@lmazuel

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,

Activity

  1. jpellerin commented on Aug 20, 2012

    @jpellerin
    Member

    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?

  2. jpellerin commented on Aug 21, 2012

    @jpellerin
    Member

    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:

    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.

  3. lmazuel commented on Aug 22, 2012

    @lmazuel
    Author

    Thanks for your answer, I will consider this way too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions