【问题标题】:Various errors running unit tests with TYPO3 testing framework使用 TYPO3 测试框架运行单元测试的各种错误
【发布时间】:2017-06-19 16:10:09
【问题描述】:

我正在尝试使用本地的、基于作曲家的 TYPO3 8.7 安装来为我的一些扩展运行单元测试。这是我的作曲家文件:

{
  "repositories": [
    { "type": "vcs", "url": "https://git.typo3.org/Packages/TYPO3.CMS.git" },
    { "type": "vcs", "url": "https://github.com/cobwebch/external_import.git"},
    { "type": "vcs", "url": "https://github.com/fsuter/externalimport_test.git"},
    { "type": "vcs", "url": "https://github.com/cobwebch/svconnector.git"},
    { "type": "vcs", "url": "https://github.com/cobwebch/svconnector_csv.git"},
    { "type": "vcs", "url": "https://github.com/cobwebch/svconnector_feed.git"},
    { "type": "vcs", "url": "https://github.com/cobwebch/svconnector_json.git"},
    { "type": "vcs", "url": "https://github.com/cobwebch/svconnector_sql.git"}
  ],
  "name": "my-vendor/my-typo3-cms-distribution",
  "require": {
    "typo3/cms": "TYPO3_8-7-dev",
    "cobweb/external_import": "dev-wombat",
    "cobweb/externalimport_test": "dev-master",
    "cobweb/svconnector": "dev-master",
    "cobweb/svconnector_csv": "dev-master",
    "cobweb/svconnector_feed": "dev-master",
    "cobweb/svconnector_json": "dev-master",
    "cobweb/svconnector_sql": "dev-master"
  },
  "extra": {
    "typo3/cms": {
      "cms-package-dir": "{$vendor-dir}/typo3/cms",
      "web-dir": "web"
    }
  },
  "require-dev": {
    "nimut/testing-framework": "^1.1"
  }
}

我不明白 TYPO3 的哪些部分在从命令行运行单元测试时在引导过程中被初始化,但似乎不完整。

案例:当我尝试使用(在“web”文件夹中)对扩展“svconnector_csv”运行单元测试时:

/path/to/php ../vendor/bin/phpunit -c ../vendor/nimut/testing-framework/res/Configuration/UnitTests.xml typo3conf/ext/svconnector_csv/Tests/Unit/

所有测试都失败,报告找不到服务密钥“tx_svconnectorcsv_sv1”的异常。签入后端(使用报告模块)时,该服务安装正常。

另一个错误,但也是一个问题,当使用类似的命令运行扩展“external_import”的测试时。我收到错误消息,表明 TCA 未加载。

是否可以以任何方式影响已处理的引导程序以确保加载 TCA 和 T3_SERVICES 等全局数组?或者他们应该是,我在我的设置中遗漏了一些东西?

作为参考,这里是两个扩展的源代码链接:

【问题讨论】:

  • 可能是测试框架有自己的安装,但没有安装该服务?

标签: phpunit typo3 typo3-8.x


【解决方案1】:

我也使用这个测试框架。我在 GitLab CI 中使用它并运行我的扩展:

.Build/bin/phpunit -c Configuration/.Build/Tests/UnitTests.xml

我的 UnitTests.xml:

<phpunit
    backupGlobals="true"
    backupStaticAttributes="false"
    bootstrap="../../../.Build/vendor/nimut/testing-framework/src/TestingFramework/Bootstrap/UnitTestsBootstrap.php"
    colors="true"
    convertErrorsToExceptions="true"
    convertWarningsToExceptions="true"
    forceCoversAnnotation="false"
    processIsolation="false"
    stopOnError="false"
    stopOnFailure="false"
    stopOnIncomplete="false"
    stopOnSkipped="false"
    verbose="false"
>
    <testsuites>
        <testsuite name="Base tests">
            <directory>../../../Tests/Unit</directory>
        </testsuite>
    </testsuites>
</phpunit>

希望,它会有所帮助。

【讨论】:

    猜你喜欢
    • 2019-10-26
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多