# Using Test IDs

Allow easy test selection with test ids.

Assigns (and, in verbose mode, prints) a sequential test id for each test executed. Ids can be fed back in as test names, and this plugin will translate them back to full test names. Saves typing!

This plugin implements `reportStartTest()`, `loadTestsFromName()`, `loadTestsFromNames()` and `stopTest()`.

## 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

    [unittest]
    plugins = nose2.plugins.testid

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

## Configuration [testid]

always-on
  Default:

    False

  Type:

    boolean

id-file
  Default:

    .noseids

  Type:

    str

### Sample configuration

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

    [testid]
    always-on = False
    id-file = .noseids

## Command-line options

-I DEFAULT, --with-id DEFAULT

  Add test ids to output

## Plugin class reference: TestId

class nose2.plugins.testid.TestId(*args, **kwargs)

  Allow easy test select with ids

  loadIds()

    Load previously pickled ‘ids’ and ‘tests’ attributes.

  loadTestsFromName(event)

    Load tests from a name that is an id

    If the name is a number, it might be an ID assigned by us. If we can find a test to which we have assigned that ID, event.name is changed to the test’s real ID. In this way, tests can be referred to via sequential numbers.

  loadTestsFromNames(event)

    Translate test ids into test names

  nextId()

    Increment ID and return it.

  reportStartTest(event)

    Record and possibly output test id

  stopTestRun(event)

    Write testids file