Use asserts in ApiTester.
[RuntimeException] Call to undefined method ApiTester::assertEquals
Provide console output if related. Use
-vvvmode for more details.
Codeception PHP Testing Framework v2.3.6
Powered by PHPUnit 6.4.4 by Sebastian Bergmann and contributors.
Test.api Tests (1) --------------------------------------------------------------------------------------------------------
Modules: Asserts, REST, Laravel5, \Test\Helper\Api
---------------------------------------------------------------------------------------------------------------------------------
TestCest: Test
Signature: TestCest:test
Test: tests/api/Http/Controllers/v1/TestCest.php:test
Scenario --
[Database] Transaction started
ERROR
[Database] Transaction cancelled; all changes reverted.
---------------------------------------------------------------------------------------------------------------------------------
Time: 5.97 seconds, Memory: 14.00MB
There was 1 error:
---------
1) TestCest: Test
Test tests/api/Http/Controllers/v1/TestCest.php:test
[RuntimeException] Call to undefined method ApiTester::assertEquals
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Actor.php:44
/home/vagrant/Code/api.application.app/public_html/modules/Test/Tests/tests/api/Http/Controllers/v1/TestCest.php:61
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Lib/Di.php:127
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Test/Cest.php:136
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Test/Cest.php:148
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Test/Cest.php:82
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Test/Test.php:87
/home/vagrant/Code/api.application.app/public_html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php:106
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/SuiteManager.php:157
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Codecept.php:188
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Codecept.php:157
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Command/Run.php:341
/home/vagrant/Code/api.application.app/public_html/vendor/symfony/console/Command/Command.php:240
/home/vagrant/Code/api.application.app/public_html/vendor/symfony/console/Application.php:860
/home/vagrant/Code/api.application.app/public_html/vendor/symfony/console/Application.php:218
/home/vagrant/Code/api.application.app/public_html/vendor/symfony/console/Application.php:122
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/src/Codeception/Application.php:103
/home/vagrant/Code/api.application.app/public_html/vendor/codeception/codeception/codecept:36
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Provide test source code if related
<?php
class TestCest
{
/**
* Api Helper
*
* @var \Helper\Api
*/
protected $api;
/**
* Load required helpers for cest
*
* @param \Helper\Api $api
*/
protected function _inject(\Helper\Api $api): void
{
$this->api = $api;
}
/**
* Actions executed before cest
*
* @param ApiTester $I
*/
public function _before(ApiTester $I): void
{
}
/**
* Actions executed after cest
*
* @param ApiTester $I
*/
public function _after(ApiTester $I): void
{
}
public function test(ApiTester $I)
{
$I->assertEquals(1, 1);
}
}
composer show)class_name: ApiTester
modules:
enabled:
- Asserts
- REST:
url: /v1/sportsbook
depends: Laravel5
- Laravel5:
bootstrap: ../../../bootstrap/app.php
vendor_dir: ../../../vendor
environment_file: .env.testing
cleanup: true
run_database_migrations: true
- \Sportsbook\Helper\Api
One possible sulution is to include \Codeception\Util\Shared\Asserts trait But still not sure about why I'm not able to call directly through ApiTester.
Strange... It should be there!
COuld you try to executed
codecept build
and try to look into _support/_generated/ApiActions.php to see if assertions are there
Worked like a charm!
Wow! Thank you. It's only require to adding " - Asserts" module in config file and run codecept build!
Most helpful comment
Wow! Thank you. It's only require to adding " - Asserts" module in config file and run codecept build!