I'm totally new to codeception and I'm just after installing it into my yii2 project.
First I run: alias codecept="./vendor/bin/codecept"
Then I run: codecept bootstrap
and then: codecept generate:cept acceptance SmokeTest
and I don't see SmokeTestCept.php file in tests/codeception/acceptance. I can't figure out what is wrong. Any help please?
Related
I am planning to convert my testcafe console output to txt/html file with custom file name, I am using below line of script, but output file is not generating and no errors. I have installed the required report templates. Please guide me .
$ testcafe chrome tests/core/sample.test.js --reporter html:/file.html
$ testcafe chrome tests/core/sample.test.js --reporter list:/test.txt
Thanks
Ramesh D
console output to txt
Isn't this just easier?
$ testcafe chrome tests/core/sample.test.js > test_output.txt 2>&1
I mean you can use reporters, you can build your own reporter and spend hours on that, or if you really just need a file out of console output, this should be enough.
console output to html
I have a habit of using config files rather than command line options, so I'll show it on config files:
.testcaferc.json
{
"reporter": [
{
"name": "html",
"output": "Results/report.html"
}
]
}
First, of course, you need to install the appropriate npm package:
$ npm install --save-dev testcafe-reporter-html
If you insist on a command-line option, this testcafe docs should guide you. I believe this would be the right command:
$ testcafe chrome tests/core/sample.test.js -r html:Results/report.html
If I am able to get the filename of the failed test, I could run the test a second time to check if it really is a error or just a coincidence. Until now I couldnt find a sulution.
You get the instance of test in _failed hook, so you can do the same thing as RunFailed extension:
use Codeception\Test\Descriptor;
public function _failed(\Codeception\TestInterface $test, $fail)
{
$fullName = Descriptor::getTestFullName($test);
}
Original answer:
Codeception has RunFailed extension, which is enabled by default.
It saves the names of all failed tests to tests/_output/failed file, and failed tests can be executed by running codecept run -g failed command.
In order to make CI pass if failed tests pass on second run you can use this command:
codecept run || codecept run -g failed
I am working with Codeception Acceptance Tests in docker containers.
I can run the whole project, but I can't run single tests or classes.
Is there any configuration option or parameter to solve this?
This works (run all tests):
codecept -c /app/web/codeception.yml run
This does not work:
codecept -c /app/web/codeception.yml run SupplierFormCest (class name)
codecept -c /app/web/codeception.yml run Tests/SupplierFormCest (Namespace path)
codecept -c /app/web/codeception.yml run /app/web/tests/acceptance/SupplierFormCest (file path)
Error Message: Suite 'SupplierFormCest' could not be found
Looks like you need to specify the suite, acceptance, before the class name:
codecept -c /app/web/codeception.yml run acceptance SupplierFormCest
[![Try to run from ruby mine]I was not able to rerun failed automated test scenarios by using yml file example default: --no-source --color cucumber -f rerun --out rerun.txt
Try the Runner Options. Steps: Open Feature file > Run menu > Edit Configuration > Cucumber > Add/Edit existing > Update Runner Options.
I'm using Codeception and I want to do Selenium tests.
Obviously, I need Selenium server running and I can spin it up with:
java -jar ./path/to/selenium/binary
However, I've used another testing framework in past which allowed me to specify this path in config file. Then, whenever I did something like codecept run, the framework automatically started selenium server and also shutted it down after all tests were completed.
Can I do this with Codeception? I tried to put exec() in _bootstrap file but it didn't work..
I'm using phantomjs - headless alternative to selenium. This extension starts phantomjs automatically with codecept run. Also phantomjs is faster than selenium.
You can write your own extension for running selenium - have a look at this file.
I start my tests with a bash script and then start and stop selenium via screen:
#!/usr/bin/env bash
# Start selenium in detached screen
screen -d -m -S "selenium" java -Dwebdriver.chrome.driver=./path/to/chromedriver -jar ./path/to/selenium/binary || true
./vendor/bin/codecept run -c codeception.yml --fail-fast --coverage --steps --coverage-html --html || error=true
# quit selenium
screen -S selenium -X quit || true
This might not fit the use-case but I can execute my code in my bash on Windows and Ubuntu as well as via my jenkins build process.