# Loader: Parameterized Tests

Load tests from parameterized functions and methods.

This plugin implements `getTestCaseNames()`, `loadTestsFromModule()`, and `loadTestsFromName()` to support loading tests from parameterized test functions and methods.

To parameterize a function or test case method, use `nose2.tools.params()`.

To address a particular parameterized test via a command-line test name, append a colon (‘:’) followed by the index (starting from 1) of the case you want to execute.

## Such And The Parameters Plugin

The parameters plugin can work with the Such DSL, as long as the first argument of the test function is the “case” argument, followed by the other parameters:

    from nose2.tools import such
    from nose2.tools.params import params

    with such.A('foo') as it:
        @it.should('do bar')
        @params(1,2,3)
        def test(case, bar):
            case.assertTrue(isinstance(bar, int))

        @it.should('do bar and extra')
        @params((1, 2), (3, 4) ,(5, 6))
        def testExtraArg(case, bar, foo):
            case.assertTrue(isinstance(bar, int))
            case.assertTrue(isinstance(foo, int))

    it.createTests(globals())

## Configuration [parameters]

always-on
  Default:

    True

  Type:

    boolean

### Sample configuration

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

    [parameters]
    always-on = True

## Plugin class reference: Parameters

class nose2.plugins.loader.parameters.Parameters(*args, **kwargs)

  Loader plugin that loads parameterized tests

  getTestCaseNames(event)

    Generate test case names for all parameterized methods

  loadTestsFromModule(event)

    Load tests from parameterized test functions in the module

  loadTestsFromName(event)

    Load parameterized test named on command line