2016-09-20 8 views
1

ich implementieren die Funktion in FeatureContext testen, aber ich weiß nicht, wie in behat.yml configWie Datei-Download mit Behat Version 3

Hier ist mein Code

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 

Ich weiß nicht, wie Argument übergeben hier behat.yml ist Code

suites: 
    default: 
     paths: &featurePaths 
     - '%paths.base%/features' 
     contexts: &contexts 
     - FeatureContext 

Wenn ich meinen Test ausführen es Fehlermeldung wie folgt zeigt:

[Behat \ Testwork \ Argument \ Exception \ UnknownParameterValueException] Es konnte kein übereinstimmender Wert für ein Argument $filename der Methode FeatureContext::assertFileDownloaded() gefunden werden.

Als Referenz hier How to test file download in Behat

+0

Es kann etwas nützlich für Sie in http://www.inanzzz.com/index.php/posts/behat sein – BentCoder

Antwort

0

Versuchen Sie folgendes:

/** 
* @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"); 
    } 
}