Overview

Facet Overview



The new event API is a single method: facet_data().

This method must return a hashref where each key is specific to a facet type.

The value is either a facet hashref, or an array of hashrefs.

Some facets MUST be lone hashrefs, others MUST be hashrefs inside an arrayref.

About

About

An event may only have one.

'details' is a human readable string describing the overall event.

'no_display' means that a formatter/harness should hide the event.

'package' is the package of the event the facet describes (IE: Test2::Event::Ok)

Amnesty

Amnesty

An event may have multiple.

This event is how things like 'todo' are implemented. Amnesty prevents a failing assertion from causing a global test failure.

'details' is a human readable description of why the failure is being granted amnesty (IE The 'todo' reason)

'tag' is a short human readable string, or category for the amnesty. This is typically 'TODO' or 'SKIP'.

'inherited' is true if the amnesty was applied in a parent context (true if this test is run in a subtest that is marked todo).

Assert

Assert

An event may only have one.

The 'details' key is the name of the assertion.

The 'pass' key denotes a passing or failing assertion.

The 'no_debug' key tells any harness or formatter that diagnostics should not be added automatically to a failing assertion (used when there are custom diagnostics instead).

The 'number' key is for internal use, never set it yourself.

Control

Control

An event may have one.

This facet is used to apply extra behavior when the event is processed.

'details' is a human readable explanation for the behavior.

'global' is true if this event should be forwarded to, and processed by, all hubs everywhere. (bail-out uses this)

'terminate' this should either be undef, or an integer (0-255). When defined this will cause the test to exit with the specific exit code.

'halt' is used to signal any harness that no further test files should be run (bail-out uses this).

'has_callback' is set to true if the event has a callback sub defined.

'encoding' used to tell the formatter what encoding to use.

Errors

Errors

An event may have multiple.

'details' is a human readable explanation of the error.

'tag' is a short human readable category for the error.

'fail' is true if the error should cause test failure. If this is false the error is simply informative, but not fatal.

Info

Info

An event may have multiple.

This is how diag and note are implemented.

'details' human readable message.

'tag' short category for the message, such as 'diag' or 'note'.

'debug' is true if the message is diagnostics in nature, this is the main difference between a note and a diag.

'important' is true if the message is not diagnostics, but is important to have it shown anyway. This is primarily used to communicate with a harness.

Parent

Parent

An event may have one.

This is used by subtests.

'details' human readable name of the subtest.

'hid' subtest hub id.

'children' an arrayref containing facet_data instances from all child events.

'buffered' true if it was a buffered subtest.

Plan

Plan

An event may have one.

'details' is a human readable string describing the plan (for instance, why a test is skipped)

'count' is the number of expected assertions (0 for skip)

'skip' is true if the plan is to skip the test.

'none' used for Test::More's 'no_plan' plan.

Trace

Trace

An event may have one.

This is how debugging information is tracked. This is taken from the context object at event creation.

'details' human readable debug message (otherwise generated from frame)

'frame' first 4 fields returned by caller.

'pid' the process id in which the event was created.

'tid' the thread is in which the event was created.

'cid' the id of the context used to create the event.

'hid' the id of the hub to which the event was sent.

'nest' subtest nesting depth of the event.

'buffered' is true if the event was generated inside a buffered subtest.