Giter Club home page Giter Club logo

pmmpunit's Introduction

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:

docker run -it --rm \
  -v /tests/pmmpunit/suitetest/normal/tests:/data/plugin_data/PmmpUnit/tests/ \
  # -v /path/to/plugin:/plugins/ \
  --name pmunit-test \
  ghcr.io/shockedplot7560/pmmpunit/tests-runner:latest

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.