# eric7.Testing.Interfaces.UnittestRunner

Module implementing the test runner script for the 'unittest' framework.

### Global Attributes

None

### Classes

EricTestResult | Class implementing a TestResult derivative to send the data via a network connection.

### Functions

_assembleTestCasesList | Protected function to assemble a list of test cases included in a test suite.
runtest | Function to run the tests.

## EricTestResult

Class implementing a TestResult derivative to send the data via a network connection.

### Derived from

unittest.TestResult

### Class Attributes

None

### Class Methods

None

### Methods

EricTestResult | Constructor
addError | Public method called if a test errored.
addExpectedFailure | Public method called if a test failed expected.
addFailure | Public method called if a test failed.
addSkip | Public method called if a test was skipped.
addSubTest | Public method called for each subtest to record its result.
addUnexpectedSuccess | Public method called if a test succeeded expectedly.
startTest | Public method called at the start of a test.
startTestRun | Public method called once before any tests are executed.
stopTest | Public method called at the end of a test.
stopTestRun | Public method called once after all tests are executed.

### Static Methods

None

#### EricTestResult (Constructor)

EricTestResult(writer, failfast)

Constructor

writer (EricJsonWriter)
  reference to the object to write the results to
failfast (bool)
  flag indicating to stop at the first error

#### EricTestResult.addError

addError(test, err)

Public method called if a test errored.

test (TestCase)
  reference to the test object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addExpectedFailure

addExpectedFailure(test, err)

Public method called if a test failed expected.

test (TestCase)
  reference to the test object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addFailure

addFailure(test, err)

Public method called if a test failed.

test (TestCase)
  reference to the test object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addSkip

addSkip(test, reason)

Public method called if a test was skipped.

test (TestCase)
  reference to the test object
reason (str)
  reason for skipping the test

#### EricTestResult.addSubTest

addSubTest(test, subtest, err)

Public method called for each subtest to record its result.

test (TestCase)
  reference to the test object
subtest (TestCase)
  reference to the subtest object
err (tuple)
  tuple containing the exception data like sys.exc_info (exception type, exception instance, traceback)

#### EricTestResult.addUnexpectedSuccess

addUnexpectedSuccess(test)

Public method called if a test succeeded expectedly.

test (TestCase)
  reference to the test object

#### EricTestResult.startTest

startTest(test)

Public method called at the start of a test.

test (TestCase)
  reference to the test object

#### EricTestResult.startTestRun

startTestRun()

Public method called once before any tests are executed.

#### EricTestResult.stopTest

stopTest(test)

Public method called at the end of a test.

test (TestCase)
  reference to the test object

#### EricTestResult.stopTestRun

stopTestRun()

Public method called once after all tests are executed.

Up

## _assembleTestCasesList

_assembleTestCasesList(suite)

Protected function to assemble a list of test cases included in a test suite.

suite (unittest.TestSuite)
  test suite to be inspected

Return:
  list of tuples containing the test case ID, the string representation and the short description

Return Type:
  list of tuples of (str, str)

Up

## runtest

runtest(argv)

Function to run the tests.

argv (list of str)
  list of command line parameters.

Up