Kernel::System::UnitTest::Driver

NAME

Kernel::System::UnitTest::Driver – unit test file execution wrapper

PUBLIC INTERFACE

new()

create unit test driver object. Do not use it directly, instead use:

    my $Driver = $Kernel::OM->Create(
        'Kernel::System::UnitTest::Driver',
        ObjectParams => {
            Verbose => $Self->{Verbose},
            ANSI    => $Self->{ANSI},
        },
    );

Run()

executes a single unit test file and provides it with an empty environment (fresh ObjectManager instance).

This method assumes that it runs in a dedicated child process just for this one unit test. This process forking is done in Kernel::System::UnitTest, which creates one child process per test file.

All results will be collected and written to a var/tmp/UnitTest.dump file that the main process will load to collect all results.

True()

test for a scalar value that evaluates to true.

Send a scalar value to this function along with the test's name:

    $UnitTestObject->True(1, 'Test Name');

    $UnitTestObject->True($ParamA, 'Test Name');

Internally, the function receives this value and evaluates it to see if it's true, returning 1 in this case or undef, otherwise.

    my $TrueResult = $UnitTestObject->True(
        $TestValue,
        'Test Name',
    );

False()

test for a scalar value that evaluates to false.

It has the same interface as "True()", but tests for a false value instead.

Is()

compares two scalar values for equality.

To this function you must send a pair of scalar values to compare them, and the name that the test will take, this is done as shown in the examples below.

    $UnitTestObject->Is($A, $B, 'Test Name');

Returns 1 if the values were equal, or undef otherwise.

    my $IsResult = $UnitTestObject->Is(
        $ValueFromFunction,      # test data
        1,                       # expected value
        'Test Name',
    );

IsNot()

compares two scalar values for inequality.

It has the same interface as "Is()", but tests for inequality instead.

IsDeeply()

compares complex data structures for equality.

To this function you must send the references to two data structures to be compared, and the name that the test will take, this is done as shown in the examples below.

    $UnitTestObject-> IsDeeply($ParamA, $ParamB, 'Test Name');

Where $ParamA and $ParamB must be references to a structure (scalar, list or hash).

Returns 1 if the data structures are the same, or undef otherwise.

    my $IsDeeplyResult = $UnitTestObject->IsDeeply(
        \%ResultHash,           # test data
        \%ExpectedHash,         # expected value
        'Dummy Test Name',
        \@Exclude,              # optional list of elements to exclude
    );

IsNotDeeply()

compares two data structures for inequality.

It has the same interface as "IsDeeply()", but tests for inequality instead.

AttachSeleniumScreenshot()

attach a screenshot taken during Selenium error handling. These will be sent to the server together with the test results.

    $Driver->AttachSeleniumScreenshot(
        Filename => $Filename,
        Content  => $Data               # raw image data
    );
Scroll to Top