unit-testing - SilverStripe Behat 抛出错误:在 null 上调用成员函数 manage() (Behat\Testwork\Call\Exception\FatalThrowableError)
问题描述
我正在从事 SilverStripe 项目。我正在使用 Behat 为我的应用程序编写行为测试。但是当我运行测试时,我在控制台中遇到错误。以下是我为我的项目设置 Behat 的方式。
我创建了一个具有以下定义的功能文件
Feature: ls
In order to see the directory structure
As a UNIX user
I need to be able to list the current directory's contents
Scenario: List 2 files in a directory
Given I am in a directory "test"
And I have a file named "foo"
And I have a file named "bar"
When I run "ls"
Then I should get:
"""
bar
foo
"""
这是我的测试课
class FeatureContext extends SilverStripeContext
{
/**
* @Given I am in a directory :arg1
*/
public function iAmInADirectory($arg1)
{
return new PendingException();
}
/**
* @Given I have a file named :arg1
*/
public function iHaveAFileNamed($arg1)
{
return new PendingException();
}
/**
* @When I run :arg1
*/
public function iRun($arg1)
{
return new PendingException();
}
/**
* @Then I should get:
*/
public function iShouldGet(PyStringNode $string)
{
assertEquals(1, 1);
}
}
当我运行测试时,我在控制台中收到以下抱怨。
┌─ @BeforeScenario # SilverStripe\Framework\Tests\Behaviour\FeatureContext::before()
│
╳ Fatal error: Call to a member function manage() on null (Behat\Testwork\Call\Exception\FatalThrowableError)
│
我的代码有什么问题,如何摆脱该错误?
解决方案
推荐阅读
- angular - 网络提供商出了问题?
- spring-boot - 数据表加载太慢
- autodesk-forge - 使用设计自动化 API 将 Revit 打印到 PDF - 不允许打印机设置、任何其他解决方法或解决方案
- android - JSONObject Azure 函数
- reactjs - 如何将 React 代码转换为 ClojureScript 代码?
- python - 不能声明双数组?
- javascript - 如何将请求 ID 值传递给模态?
- angular - Angular 7 Service 是未定义的异常
- excel - 修改通过 VBA IDE 创建的子和函数体的任何可能性
- swift - 结构作为具有完成功能的函数中的参数 - Swift