我在FeatureContext中实现了该功能,但我不知道如何在behat.yml中配置
FeatureContext.php
/**
* @Then /^the file ".+" should be downloaded$/
* @param $filename
*
* @throws \Exception
*/
public function assertFileDownloaded($filename) {
if (!file_exists('/download/dir/' . $filename)) {
throw new Exception("Can not download");
}
}
Download.feature
Scenario: Download unlock documents with Success Stories
When I am on "managed-security-services/downloads/"
Then I should be on "/managed-security-services/downloads/"
And I should see "Bühler"
Then I click on the text "Bühler"
And I wait for "1" seconds
And the file ".+" should be downloaded
我不知道如何将参数传递给behat.yml 这是代码
suites:
default:
paths: &featurePaths
- '%paths.base%/features'
contexts: &contexts
- FeatureContext
当我运行测试时,会显示如下消息错误:
的参考[Behat \ Testwork \ Argument \ Exception \ UnknownParameterValueException]找不到方法
$filename
的参数FeatureContext::assertFileDownloaded()
的匹配值。
答案 0 :(得分:0)
试试这个:
/**
* @Then /^the file :filename should be downloaded$/
*
* @throws \Exception
*/
public function assertFileDownloaded($filename) {
if (!file_exists('/download/dir/' . $filename)) {
throw new Exception("Can not download");
}
}