简约的PHP单元测试库

dev-master 2019-06-01 12:51 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:25 UTC


README

sido (시도) 的意思是:尝试/尝试

一个非常简约的PHP单元测试库。

如果你觉得这个库很有用,请考虑在 GitHub 仓库 上给它加星标。这将使我们的夜晚星空更加美丽。⭐

在这里阅读文档

安装

composer require --dev eddiejibson/sido:dev-master

为什么选择sido?

  • 简单轻盈
  • 提供类似junit风格的测试报告生成功能 - 适用于CircleCI等平台立即使用(无需自己特别格式化)
  • 0个composer依赖
  • 少量断言(易于上手)但仍然提供了你需要的一切
  • 通过webhook提供Discord通知实用工具(在测试完成后轻松通知你和你团队)

基本示例

require "/vendor/autoload.php"; //Require composer's autoload

//Custom options can be set. All are Optional
$options = [
    "report" => dirname(__FILE__) . "/reports/" . "report.xml", //Report location. Set to false to disable generation fully.
    //On test completion, webhooks can be run. You can set some here.
    "discord" => [ //Discord webhook settings. If not set, will default to false (not used)
        "webhook" => "https://discordapp.com/api/webhooks/id/token", //Your Discord webhook URL. 
        //This can be created by editing the Discord channel and navigating to the 'webhooks' section
        "name" => "Eddie's test runner" //The name of the bot. This is Optional
    ]
];

//Intialize the Sido class and pass the options defined into it.
//The options array is not required and you may pass in nothing.
$sido = new \eddiejibson\Sido($options);

//Set the test you're currently running
$sido->setTest("Array test");

//Test array we will be using
$array = ["hello" => true];

//Add testcases to the test
$sido->should(is_array($array), "Be an array");
$sido->should(count($array) > 0, "Have a length greater than 0");

//Add another test
$sido->setTest("Random test");

//Add a testcase to this test
$sido->should((1 == 1), "1 should equal 1");

//And that's pretty much it...

如何将Sido与CircleCI集成以进行自动化测试的示例

文档

完整的文档可以在这里查看.