Download the PHP package shockedplot7560/unit-test without Composer
On this page you can find all versions of the php package shockedplot7560/unit-test. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shockedplot7560/unit-test
More information about shockedplot7560/unit-test
Files in shockedplot7560/unit-test
Package unit-test
Short Description Integration testing framework for PocketMine-MP
License
Informations about the package unit-test
PmIntegration - Integration Testing Framework for PocketMine
Run only on Unix (Linux, Mac)
This plugin has been created with the sole aim of making integration and functional tests possible during the pocketmine runtime.
It can be used to correctly test the expected result of a command executed by a fake player, interaction with events and multi-threading support.
Tests are run asynchronously using promises to enable support with different systems in place. The libraries used for the promises are : ReactPHP/promise
[!WARNING] This plugin should not be used in production, as it will shutdown the server as soon as testing is complete.
Installation
Using of official docker image is strongly recommended.
Mount your tests in /data/plugin_data/PmmpUnit/tests/
and copy your plugin in /plugins/
.
Exemple:
[!NOTE] An action to simplify the execution of integration tests in a github workflow should be available soon.
Utilisation
Tests are retrieved from the folder: plugin_data/PmmpUnit/tests/
and are executed when the server start.
All test classes must inherit from ShockedPlot7560\PmmpUnit\framework\TestCase
.
All test methods must be prefixed with test
and must not have any parameters, it must return a PromiseInterface<null>
.
If the code is executed synchronously and does not have to wait for a result, use resolve(null)
.
Use Deferred
instead for asynchronous code and $deferred->resolve(null)
to resolve the promise.
Each test class can execute code when the server is onLoad
, onEnable
or onDisable
. Simply use the corresponding classes.
setUp
and tearDown
are called when each class test is run, respectively before and after the test, whatever the result.
For exemple tests, look at
tests/pmmpunit/suitetest/*/tests
TestPlayer utilisation
To retrieve one player during a test, call getPlayer()
.
To test player commands or behavior, create your promise/listener before executing the action. Return the promise in the test method.
All versions of unit-test with dependencies
react/promise Version ^3.0
webmozart/assert Version ^1.11
pocketmine/callback-validator Version ^1.0
respect/stringifier Version ^2.0
sof3/await-generator Version ^3.6