Using Codeception acceptance tests I need to check some behaviors with and without Javascript. Right now, using Seleniun I can run all tests with Javascript enabled, and using PhpBrowser I can run all tests without javascript. But how can I do for running some tests with javascript and some tests without javascript?
Codeception has several methods of sorting tests:. "groups" "environments" and "suites". Either environments or suites could be used to run tests acceptance tests with different drivers. You can create a new suite on the command line with
codecept generate suite mySuite
Then just modify mySuite.yml and you're good to go.
Related
Beginner question here but is it possible to run a PHPSpec test suite that contains tests that make REST calls without actually running a server.
Yes, you can by mocking the service that makes the calls BUT TDD/BDD (and so PHPSpec) are not meant to be used for those kind of test that are integration tests
For those kind of test I would recommend to use something like Behat
I am currently creating a project using symfony2, i am using PHPUnit vendor to functional test my code.
I am facing a problem that the functional test time increases as the projects gets bigger.
Note: i am using Fixtures to be loaded for every functional test function.
My question here? what is the best practice to implement functional test that run in a reasonable time.
on another hand, Is there any bundle or tool that i can use to speedup this process?
Your question is complex and it is very hard to say exactly problem of delay.
First of all you can divide your fixtures that possible to load before your test suit and other part that can be loaded via setUp method.
2nd advice that can really speedup you tests process is multi-threads run. I use "fastest" lib that allow me to speed up my tests in about 3-4 times (on i7) in compare with one thread run.
https://github.com/liuggio/fastest
find tests/ -name "*Test.php" | ./bin/fastest "bin/phpunit -c app {};"
Just some addition about arguments for unit/functional test. As I see the topic is about "functional" tests and if the tool is PhpUnit, it doesn't mean that tests must be "unit", because it is possible to make functional tests with it too, but I believe that it is not the best choice of the tool for functional tests.
I will recommend you take a look to other a great tool for functional tests like Behat (http://behat.org). It will allow you to not only work with functional tests more comfortable, but use BDD(Behavior Driven Development) approach for your development process
Just small example how we use it for functional testing of shopping cart http://www.youtube.com/watch?v=XIUmDGaaZWM
I am currently working on test solutions, so far I have been implementing:
Unit Test
Functional Test
Both with Codeception, a php test framework.
I want to run an acceptance test but the phpBrowser module is for non javasript pages.
I came accross Phantomjs and Selenium.
I am asking which solution is better, before jumping into the code.
Selenium is a set of different software tools each with a different approach to supporting test automation.
It allow to mimic the user interaction with the application, it can be well coupled with codeception as well.
it uses the webDriver of codeception as shown on this example:
codeception website with selenium
On the other hand:
PhantomJS is a headless alternative to Selenium Server that implements the WebDriver protocol. It allows you to run Selenium tests on a server without a GUI installed.
As seen here
I am new to testing. All i knew was we PHPunit for testing various functions within class and then i know selenium for browser testing.
I know we can write php to link with selenium web driver to do headless testing of browser.
I am not able to get how does behat and mink come in there. Are these seperate from selenium and they are the alternatives of selenium.
Can i do aweb application tetsing without beaht, mink and only with selenium and php
PHPUnit and Behat are similar, both being testing frameworks. They allow you to test your code, by using different approaches:
PHPUnit tests are based on code you write to check how your classes behave under the required circunstances. A lot of people use this type of framework to practice TDD, but you can of course write tests after the code, or for code written a long time ago.
Behat tests are written in a human readable way, and they are supposed to allow everyone involved in the project to read them. This type of testing is called BDD. You can write tests that explain in (nearly) plain english how your system is supposed to behave.
IMO PHPUnit is more general and is the preferred way of writing most tests. I use Behat for testing my systems general behavior, and PHPUnit for unit testing every class and method independently of others.
On the other side, Mink is a library that allows you to browse programatically, using PHP, and access the contents. It can be used to control in a unified way a lot of browsing systems like Selenium, Zombie, etc. each of them based on different technologies.
You can use Mink outside Behat, but they are usually used together because this way you can write tests that show how a website behaves: Given I enter my credentials in the login form, And press the submit button, I should see my profile page...
And yes, you can use PHPUnit and Selenium together as explained in the docs...
I've got an application developed in kohana 3.2. I want to write some functional tests that will affect database content. I would like to load the database from a dump file each time I run all functional test suite (so that I'm sure I can write and remove from the database as much as I want).
How can I do that in Kohana? Does it support functional testing anyhow?
Kohana supports unit testing with the unit test module and php unit installed. It sounds like you may be possibly want to do unit testing with mock objects. You could also set up your database using your models or a dump file too. Full functional testing is possible as well. A good place to start is enable the testing module and then start here...
https://github.com/kohana/unittest/tree/3.2/master/guide
And phpunit here...
https://github.com/sebastianbergmann/phpunit/
I use Codeception for all of my acceptance test, functional tests, and unit tests which is powered by PHPUnit. It is the best testing framework that I have found for PHP. You can pre-load sql dumps prior to functional tests and query directly against the database. It also integrates easily with Selenium for testing browsers.
I released a vagrant development environment with an empty checkout of Kohana 3.3.1 if you want to try it out Codeception. The tests are incredibly easy to write.
Intro to Vagrant with Kohana and Zen Kommerce
Codeception