In order to record my tests I run codeception with this command
codecept --ext Recorder
However I can't manage to record anything. Does one see what I'm doing wrong?
Codeception Recorder is disabled, no available modules:
gravityflow/codeception.dist.yml
gravityflow/plugin/tests/acceptance-tests/acceptance.suite.yml:
You're using the WordPress module, WPWebDriver. You need to tell recorder it's active. Put this in your main codeception.yml file:
extensions:
enabled:
- Codeception\Extension\RunFailed
- Codeception\Extension\Recorder
config:
Codeception\Extension\Recorder:
delete_successful: false
module: WPWebDriver
Related
I have an application with different modules. For each module, there are separate tests written which are divided in different suites.
For example in tests/Custom/codeception.yml
namespace: Test\Custom
paths:
tests: .
data: _data
support: _support
log: _output
coverage:
enabled: true
remote: false
whitelist: { include: ['../../../../src/*'] }
suites:
Business:
path: Business
...
View:
path: View
....
So every module has its own codeception.yml.
To have one "master config" there is a codeception.yml in the first level of the test folder which is including all the subfolder module yml with
namespace: Test
actor: Tester
include:
- tests/*
...
When running a build caused by a branch update in the repository we usually don't want to run other tests than business because they are slow and fragile.
For this i try to run codecept run Business and expect, that just the Business suites from the included files will be executed.
But this will not work, instead i get the error message
Suite 'Business' could not be found
But when i run one module explicit with Business suite
codecept run -c tests/Custom Business
it works.
My first assumption was, that the files get not proper included to the master yml so i tried the general call
codecept run
and it works! But this unfortunately runs all suites.
So, why the suites cant be seen by the master codeception.yml? How can i run all tests Business suites without pointing explicit to the module path?
Thanks
everyone!
I have been trying to configure Codeception 2.3.6 with Laravel 5.3.30 running on PHP 7.0.23 powered by WAMP 3.1.0. My functional test cases are running fine, but when I try to run my acceptance test cases, a new chrome window opens and then closes without doing anything.
The output in the HTML Report is Codeception Results OK(0s), while the output on the command line is:
WelcomeCept: Perform actions and see result (0.00s)
Time: 3.24 seconds, Memory: 22.75MB
OK (1 test, 0 assertions)
HTML report generated in file://D:\wamp\www\myApp\tests/_output\report.html
First I start ChromeDriver with the command
chromedriver --url-base=/wd/hub
Then I start Selenium Standalone Server 3.13.0 with the command:
java -Dwebdriver.chrome.driver="chromedriver" -jar selenium-server-standalone-3.13.0.jar -port 4445
Then I run my acceptance test suite which contains a single test file, with the command:
call vendor/bin/codecept run acceptance --html
My acceptance.suite.yml is:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://lcms.com/
window_size: false # disabled in ChromeDriver
port: 9515
browser: 'chrome'
restart: true
wait: 200
capabilities:
unexpectedAlertBehaviour: 'accept'
webStorageEnabled: true
javascriptEnabled: true
- Laravel5:
part: ORM
cleanup: false # can't wrap into transaction
environment_file: .env
- \Helper\Acceptance
My WelcomeCept.php file, just for testing the configuration, is:
<?php
class WelcomeCept
{
public function welcomeTest(AcceptanceTester $I)
{
$I->wantTo('perform actions and see result');
}
}
Please review my workflow and let me know if I'm doing things incorrectly or am missing something.
Thanks!
Update: Same thing is happening using GeckoDriver or PhantomJS in WebDriver mode. The tests are passing with OK but not performing any actions.
Solved! I tried WelcomeCest instead of WelcomeCept and things have fallen into place.
I have set up a functional test following the tutorials at:
http://codeception.com/docs/04-FunctionalTests
http://codeception.com/docs/modules/Symfony
http://codeception.com/09-04-2015/using-codeception-for-symfony-projects.html
The main difference is that I've set up Codeception the traditional way because I don't want to mix test code with project code.
This is my functional test (I know it's not actually testing anything):
<?php
class MyFirstCest {
public function _before(FunctionalTester $I) {
}
public function _after(FunctionalTester $I) {
}
// tests
public function tryToTest(FunctionalTester $I) {
$I->amOnPage('/app/login/');
}
}
When I run the functional test I get:
[RuntimeException] Call to undefined method FunctionalTester::amOnPage
When I rebuild Codeception, I get:
Building Actor classes for suites: acceptance, functional, unit
-> AcceptanceTesterActions.php generated successfully. 0 methods added
\AcceptanceTester includes modules: PhpBrowser, \Helper\Acceptance
-> FunctionalTesterActions.php generated successfully. 0 methods added
\FunctionalTester includes modules:
-> UnitTesterActions.php generated successfully. 0 methods added
\UnitTester includes modules: Asserts, \Helper\Unit
The critical part seems to be \FunctionalTester includes modules: which is empty.
My functional.suite.yml file looks like this:
actor: FunctionalTester
modules:
- Symfony:
app_path: 'app'
environment: 'local_test'
class_name: FunctionalTester
modules:
enabled:
- Symfony2:
app_path: 'path/to/app'
var_path: 'path/to/app'
- Doctrine2:
depends: Symfony2
- \Helper\Functional
- PhpBrowser:
url: dev.hmr-app
- \AcmeBundle\Helper\Functional
where the Symfony app lives in path/to/app. I know there's a lot of junk in there, but that's because I've been experimenting, trying to get it to work.
What am I doing wrong?
I think that your problem is that you have
modules:
- Symfony:
app_path: 'app'
environment: 'local_test'
in the config.
That section is completely misplaced and it probably is causing you issues.
Please remove it and rename Symfony2 with Symfony in enabled section.
Also make sure that you are using the latest version of Codeception.
I am writing acceptance codeception tests on a web application. It will require me to check headers, specifically response codes. I have found that the codeception REST module can be used, but it appears to require phpbrowser. I am required though to use browserstack. How would the configuration look using browserstack as aposed to phpbrowser.
My acceptance.suite.yml is currently set up like:
chrome-dev:
modules:
enabled:
- WebDriver
- \Helper\
config:
WebDriver:
url: 'https://XXXXXXXXXXXXXXXXXX.com'
host: 'XXXXXXXX#XXXXXXXX.com:XXXXXXXXXX.browserstack.com'
port: 80
browser: 'chrome'
window_size: maximize
capabilities:
'os': 'Windows'
'os_version': '10'
'browser_version': '57'
'acceptSslCerts': true
'resolution': '1600x1200'
'browserstack.chrome.enablePopups': true
'browserstack.chrome.allowAllCookies': true
My question here is how would I insert the REST module without using phpbrowser? It appears that it may be required, but does anybody know otherwise?
It is impossible - WebDriver and REST modules are incompatible.
I'm new using codeception and i try to do a simple test: Log in and check links inside.
I'm using $I = new AcceptanceTester($scenario); in my acceptance test but i see people using WebGuy($scenario) and i don't know the difference between WebGuy and AcceptanceTester.
SigninCept.php code:
<?php
//webLOG IN
$I = new AcceptanceTester($scenario);
$I->wantTo('Log in my app mobile');
//$I->amOnUrl('192.168.X.X/app/mobile/');
$I->amOnPage('/');
$I->fillField('user','test');
$I->fillField('password','test1234');
$I->fillField('zone','01');
//$I->uncheckOption('input[type=checkbox]');
$I->seeCheckboxIsChecked('#rememberme');
$I->seeElement('input[name=submit]');
$I->click('input[type=submit]');
//succes
$I->wantTo('Check main page');
$I->amOnPage('/principal.php');
$I->seeLink('salir','salir.php');
[...]
?>
Result(cmd):
C:\xampp\htdocs\public_html\codeception>php codecept.phar run acceptance --steps
Codeception PHP Testing Framework v2.0.9
Powered by PHPUnit 4.4.0 by Sebastian Bergmann.
Acceptance Tests (1) -----------------------------------------------------------
---------------------------------------
Trying to Log in App Mobile (SigninCept)
Scenario:
* I am on page "/"
* I fill field "user","test"
* I fill field "password","test1234"
* I fill field "zone","01"
* I see checkbox is checked "#rememberme"
* I see element "input[name=submit]"
* I click "input[type=submit]"
* I am on page "/principal.php"
* I see link "salir","salir.php"
[...]
PASSED
When i use $I = new WebGuy($scenario); i get this:
C:\xampp\htdocs\public_html\codeception>php codecept.phar run acceptance --steps
Codeception PHP Testing Framework v2.0.9
Powered by PHPUnit 4.4.0 by Sebastian Bergmann.
Acceptance Tests (1) -----------------------------------------------------------
---------------------------------------
Trying to Log in App mobile(SigninCept)
Scenario:
Fatal error: Class 'WebGuy' not found in C:\xampp\htdocs\public_html\codeception\tests\acceptance\SigninCept.php on line 3
FATAL ERROR. TESTS NOT FINISHED.
Class 'WebGuy' not found
in C:\xampp\htdocs\public_html\codeception\tests\acceptance\SigninCept.php:3
I have **WebGuy.php in my acceptance dir.**
If i do build i get this:
C:\xampp\htdocs\public_html\codeception>php codecept.phar build acceptance --steps
[RuntimeException]
Too many arguments.
build [-c|--config[="..."]]
Codeception 2.x use only AcceptanceTester.
As it was said, Guys were renamed to Testers. Actor classes and
helpers are named by suite. For instance, acceptance test will start
with this line:
<?php
$I = new AcceptanceTester($scenario);
// and uses AcceptanceHelper
?>
See here : http://codeception.com/06-06-2014/codeception-2.0-final.html
The name of the "guy" depends on what you have in codeception configuration of your suite (in your case the acceptance suite):
# acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
...
When running codecept build the guy class will be created integrating all the methods of the modules you have defined, and it will then used by CodeCeption when running the tests. Any other classes will be ignored.
Also see the help for the build command (codecept help build) to see what options you can pass to it (i.e. normally you don't need any option).
the WebGuy class is only a custom class that extends from the AcceptanceTester Class. You can implement your own and call it from the acceptance.suite.yml
class_name: AcceptanceTester ==> or ==> WebGuy // here is the call of the class
modules:
enabled:
- WebDriver:
url: 'http://local.symmetryk.com/'
browser: firefox
window_size: maximize
wait: 10
capabilities:
unexpectedAlertBehaviour: 'accept'
env:
chrome:
modules:
config:
WebDriver:
browser: 'chrome'
- Db:
hope this will help you understand :)