joomla-projects/joomla-testing-robo

此软件包已废弃,不再维护。未建议替代包。

Joomla 自动化测试瑞士军刀

1.0.3 2020-11-27 16:28 UTC

This package is auto-updated.

Last update: 2020-11-27 16:29:03 UTC


README

瑞士军刀,用于向您的 Joomla 扩展添加自动化测试,使用 Robo.li 进行任务定义。

安装

  • composer install

命令

所有包含的命令都有设置器和实际要执行的功能(使用前面的设置器)。它们被设计为可以堆叠并由 robo run() 命令在最后执行。

SeleniumStandaloneServer

允许执行与 Selenium 服务器(不包括在内)相关的任务。

设置器

  • setBinary($binary): 设置 Selenium 服务器二进制文件的路径。默认:vendor/bin/selenium-server-standalone
  • setURL($url): 设置 Selenium 服务器的 URL。默认:http://localhost:4444
  • setDebug($debug = true): 当设置为 true 时,为 Selenium 服务器设置 -debug 选项
  • setLogFile($logFile): 定义 Selenium 服务器执行的单一日志文件。默认:selenium.log
  • setTimeOut($seconds): 设置执行时等待服务器实际运行的超时时间。默认:60
  • setWebdriver($name): 允许设置一个命名 webdriver 来运行 selenium 测试

函数

  • runSelenium(): 运行 selenium 服务器。
  • waitForSelenium(): 等待 selenium 服务器运行,使用 setTimeout 中定义的超时时间
  • killSelenium(): 使用在 setURL 中提供的 URL(或默认 URL)终止 Selenium 服务器

示例

设置 Selenium 服务器

$this->taskSeleniumStandaloneServer()
    ->setBinary('<path>/selenium-server-standalone')

    ->runSelenium()
    ->waitForSelenium()

    ->run()
    ->stopOnFail();

终止 Selenium 服务器

$this->taskSeleniumStandaloneServer()

    ->killSelenium()

    ->run();

CMSSetup

设置 CMS 以便进行测试的任务。

设置器

  • setBaseTestsPath($baseTestsPath): 设置测试文件夹的路径。 (必需)
  • setCmsRepository($cmsRepository): 设置用于克隆 CMS 存储库的 Github 所有者/客户端组合。默认:joomla/joomla-cms
  • setCmsPath($cmsPath): 设置 CMS 将安装的实际路径(Apache 文件夹)。默认:joomla
  • setCachePath($cachePath): 设置 CMS 缓存的路径。默认:cache
  • setCmsBranch($cmsBranch): 设置要克隆的 Joomla! 分支(基于存储库标签)。默认:staging
  • setCmsCache($cmsCacheTime): 设置 CMS 缓存时间(以秒为单位)。默认:86400
  • setExecuteUser($executeUser): 定义一个用户,如果需要,则更改权限。
  • setCertificatesPath($path): 定义一个路径,其中包含要添加到 Joomla 安装的额外证书(如果需要)。

函数

  • cloneCMSRepository(): 根据测试文件夹、缓存和存储库详细信息克隆存储库。
  • setupCMSPath(): 实际上使用缓存设置CMS。
  • fixPathPermissions(): 通过设置在 setExecuteUser 中给出的所有者来修复任何权限问题。
  • setupHtAccess(): 当调用时设置 .htaccess 文件。
  • appendCertificates(): 使用证书路径追加证书。这在像Travis这样的环境中是必需的,这样Joomla就不会在安装额外语言时出现问题。

示例

简单的Joomla CMS设置

$this->taskCMSSetup()
    ->setBaseTestsPath(__DIR__ . '/tests')

    ->cloneCMSRepository()
    ->setupCMSPath()

    ->run()
    ->stopOnFail();

应用设置

设置实际应用的函数。

设置器

  • setPackageCommand($packageCommand): 设置创建应用包要执行的命令。默认:gulp release
  • setPackageArgs($packageArgs): 设置要发送给包的参数。默认:--skip-version

函数

  • packageApplication(): 使用给定参数执行应用打包器。

示例

打包应用

$this->taskApplicationSetup()

    ->packageApplication()

    ->run()
    ->stopOnFail();

报告

报告失败的方 法

设置器

  • setCloudinaryCloudName($cloudinaryCloudName): 设置Cloudinary云,以便上传错误图像。
  • setCloudinaryApiKey($cloudinaryApiKey): 设置Cloudinary API密钥。
  • setCloudinaryApiSecret($cloudinaryApiSecret): 设置Cloudinary API密钥。
  • setImagesToUpload($images): 设置Cloudinary上传的图像数组。
  • setFolderImagesToUpload($path): 设置要由Cloudinary上传的完整图像文件夹。
  • setGithubToken($githubToken): 设置用于向GitHub拉取请求报告错误的GitHub令牌。
  • setGithubRepo($githubRepo): 设置GitHub仓库的所有者/仓库名组合。
  • setGithubPR($githubPR): 设置GitHub拉取请求的编号。
  • setUploadedImagesURLs($uploadedImagesURLs): 当不使用Cloudinary时,允许设置要附加到PR注释中的图像URL数组。
  • setGithubCommentBody($githubCommentBody): 设置要发送到GitHub的错误消息。如果有任何上传的图像URL(或由Cloudinary生成)它们将被附加在末尾。

函数

  • publishCloudinaryImages(): 执行将图像推送到Cloudinary的实际操作,并在调用任务时将它们设置为附加到PR注释。
  • publishGithubCommentToPR(): 使用注释体和可选的上传图像URL在GitHub中注释。

示例

实际报告到GitHub PR,包括图像

$this->taskReporting()
    ->setCloudinaryCloudName('<cloud>')
    ->setCloudinaryApiKey('<api key>')
    ->setCloudinaryApiSecret('<api secret>')
    ->setGithubToken('<github token>')
    ->setGithubRepo('<owner/repo>')
    ->setGithubPR('<PR #>')
    ->setImagesToUpload([
        '/path/to/image',
        '/path/to/image'
    [)
    ->setGithubCommentBody('<Error comment>')

    ->publishCloudinaryImages()
    ->publishGithubCommentToPR()

    ->run()
    ->stopOnFail();

代码检查

执行包含的代码测试

设置器

  • setBaseRepositoryPath($baseRepositoryPath): 设置测试将执行的基仓库路径。必需
  • setParseErrorsCheckFolders($parseErrorsCheckFolders): 要检查解析错误的文件夹数组。
  • setPhpExecutable($phpExecutable): 设置php可执行命令。默认:php
  • setDebugLeftoversFolders($debugLeftoversFolders): 设置要检查调试残留文件夹
  • setCodeStyleStandardsFolder($codeStyleStandardsFolder): 设置代码样式定义将下载/存储的文件夹(使用仓库)。
  • setCodeStyleStandardsRepo($codeStyleStandardsRepo): 设置包含代码样式定义的Github仓库(所有者/仓库名),用于下载。默认:joomla/coding-standards
  • setCodeStyleStandardsBranch($codeStyleStandardsBranch): 使用代码标准仓库的分支。默认:master
  • setCodeStyleCheckFolders($codeStyleCheckFolders): 执行代码样式检查的文件夹。
  • setCodeStyleExcludedPaths($codeStyleExcludedPaths): 排除代码样式检查的路径数组(文件/文件夹/路径模式)。

函数

  • checkForParseErrors(): 执行解析错误检查。
  • checkForDebugLeftovers(): 执行调试残留检查,查找 var_dumpconsole_log 残留。
  • checkCodeStyle(): 通过从Github下载标准,执行代码样式检查(phpcs)。

示例

执行解析错误检查

$this->taskCodeChecks()
    ->setBaseRepositoryPath(<base repository path>)
    ->setParseErrorsCheckFolders(<array of folders to check>)
    ->checkForParseErrors()
    ->run();

调试残留检查

$this->taskCodeChecks()
    ->setBaseRepositoryPath(<base repository path>)
    ->setDebugLeftoversFolders(<array of folders to check>)
    ->checkForDebugLeftovers()
    ->run();

代码样式检查

$this->taskCodeChecks()
    ->setBaseRepositoryPath(<base repository path>)
    ->setCodeStyleCheckFolders(<array of folders to check>)
    ->checkCodeStyle()
    ->run();