1
通過Dancer :: Test文檔的閱讀使測試看起來很簡單,但我錯過了一些東西。如果我有以下舞者的應用程序(WebApp.pm
):如何運行一個Perl舞者測試
package WebApp;
use Dancer;
# declare routes/actions
get '/' => sub {
"Hello World";
};
dance;
然後將下面的測試文件001_base.t
:
use strict;
use warnings;
use Test::More tests => 1;
use WebApp;
use Dancer::Test;
response_status_is [GET => '/'], 200, "GET/is found";
然後當我運行測試:perl 001_base.t
,輸出的是,舞者腳本啓動
Dancer 1.3132 server 7679 listening on http://0.0.0.0:3000
== Entering the development dance floor ...
然後等待。 (這與我在WebApp.pm中運行代碼的情況相同)。我在這裏錯過了什麼?我想我沒有正確運行測試。
這工作得很好。謝謝。如果我在WebApp.pm和'Dancer :: set port =>'3003'中使用了'set port => 3003;';''在另一個端口(比默認的3000)測試文件,它繼續工作。 –