我有一个测试文件夹结构,如:
.
├── test
│ └── e2e
│ ├── pages
│ │ └── LoginPage.php
│ └── webdriver
│ └── Browser.php
└── vendor
当我跑步时
$ vendor\bin\phpunit --bootstrap vendor/autoload.php test\e2e\HomePage.php
测试失败
Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'Browser' could not be found in 'C:\Users\rburton\code\MyAgsourceAPI\test\e2e\HomePage.php'. in C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\src\Runner\StandardTestSuiteLoader.php on line 101
PHPUnit\Runner\Exception: Class 'Browser' could not be found in 'C:\Users\rburton\code\MyAgsourceAPI\test\e2e\HomePage.php'. in C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\src\Runner\StandardTestSuiteLoader.php on line 101
Call Stack:
0.1973 357496 1. {main}() C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\phpunit:0
0.2024 746904 2. PHPUnit\TextUI\Command::main(???) C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\phpunit:53
0.2024 750064 3. PHPUnit\TextUI\Command->run(array(4), true) C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\src\TextUI\Command.php:141
0.2077 1007320 4. PHPUnit\TextUI\TestRunner->getTest(string(17), string(57), array(2)) C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\src\TextUI\Command.php:162
0.2078 1007320 5. PHPUnit\TextUI\TestRunner->loadSuiteClass(string(17), string(57)) C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:73
0.2084 1026680 6. PHPUnit\Runner\StandardTestSuiteLoader->load(string(7), string(57)) C:\Users\rburton\code\MyAgsourceAPI\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:130
我实例化Browser
类的唯一地方是HomePage
测试类的设置:
protected function setUp()
{
$this->browserDriver = new Browser();
$this->browserDriver->start('https://192.168.3.69');
}
令我困惑的是,错误表明StandardTestSuiteLoader
找不到Browser
类,而不是在实例化类的测试类中。
有没有人有一些想法为什么无法找到辅助类?
答案 0 :(得分:0)
我看起来像PHPUnit库中的selenium不能捆绑为框架。之后我转到了C#和Java的selenium库。