
########
UnitTest
########


****
NAME
****


Kernel::System::UnitTest - functions to run all or some OTRS unit tests


****************
PUBLIC INTERFACE
****************


new()
=====


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


.. code-block:: perl

     my $UnitTestObject = $Kernel::OM->Get('Kernel::System::UnitTest');



Run()
=====


run all or some tests located in \ ``scripts/test/\*\*/\*.t``\  and print the result.


.. code-block:: perl

     $UnitTestObject->Run(
         Tests                  => ['JSON', 'User'],             # optional, execute certain test files
         Directory              => ['Selenium', 'User'],         # optional, execute tests in subdirectory
         Package                => ['ITSMCore'],                 # optional, execute tests of installed package
         ExcludeDirectory       => ['Selenium/Agent/Admin'],     # optional, all test files in the specified directory will be Excluded.
         SOPMFile               => ['ITSMCore.sopm'],            # optional, execute all test files which are defined in these sopm.
         Verbose                => 1,                            # optional (default 0), only show result details for all tests, not just failing
         SubmitURL              => $URL,                         # optional, send results to unit test result server
         SubmitAuth             => $SubmitAuth,                  # optional authentication string for unit test result server
         SubmitResultAsExitCode => 1,                            # optional, specify if exit code should not indicate if tests were ok/not ok, but if submission was successful instead
         JobID                  => 12,                           # optional job ID for unit test submission to server
         Scenario               => 'Znuny 6 git',                # optional scenario identifier for unit test submission to server
         PostTestScripts        => ['...'],                      # Script(s) to execute after a test has been run.
                                                                 #  You can specify %File%, %TestOk% and %TestNotOk% as dynamic arguments.
         PreSubmitScripts       => ['...'],                      # Script(s) to execute after all tests have been executed
                                                                 #  and the results are about to be sent to the server.
         NumberOfTestRuns       => 10,                           # optional (default 1), number of successive runs for every single unit test
     );


Please note that the individual test files are not executed in the main process,
but instead in separate forked child processes which are controlled by `Kernel::System::UnitTest::Driver`.
Their results will be transmitted to the main process via a local file.


_Color()
========


this will color the given text (see L<Term::ANSIColor::color()>) if
ANSI output is available and active, otherwise the text stays unchanged.


.. code-block:: perl

     my $PossiblyColoredText = $CommandObject->_Color('green', $Text);





