Collecting tests without running them

This plugin implements startTestRun(), setting a test executor (event.executeTests) that just collects tests without executing them. To do so it calls result.startTest, result.addSuccess and result.stopTest for each test, without calling the test itself.

Enable this Plugin

This plugin is built-in, but not loaded by default.

Even if you specify always-on = True in the configuration, it will not run unless you also enable it. You can do so by putting the following in a unittest.cfg or nose2.cfg file

plugins = nose2.plugins.collect

The plugins parameter may contain a list of plugin names, including nose2.plugins.collect

Configuration [collect-only]





Sample configuration

The default configuration is equivalent to including the following in a unittest.cfg file.

always-on = False

Command-line options

--collect-only DEFAULT

Collect but do not run tests. With ‘-v’, this will output test names

Plugin class reference: CollectOnly

class nose2.plugins.collect.CollectOnly(*args, **kwargs)[source]

Collect but don’t run tests

collectTests(suite, result)[source]

Collect tests, but don’t run them


Replace event.executeTests