How to Implement Acceptance test with Codeception on Javascript Page - php

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

Related

How to run tests with and without javascript in Codeception?

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.

Codeception vs peridot + php-webdriver?

I would like to implement some basic acceptance tests for my company's legacy PHP app. Selenium WebDriver looks like the best fit, but I need advice on what testing framework to use.
Option 1
Our unit tests are written in Peridot PHP, and I know WebDriver can be run from PHP via php-webdriver. So, it looks like I should be able to write a suite of Peridot tests that use the php-webdriver API to interact with the site. It's been done for PHPUnit, and at a glance I don't see why Peridot can't do the same (gulp).
Option 2
Alternatively, I also know the Codeception framework integrates well with WebDriver. The nice thing about this is that Codeception takes care of setting up the WebDriver server and loading a test database. It also allows for a very nice, readable set of English-language tests, although it would mean maintaining two separate testing frameworks.
Considerations
How completely does Codeception cover the WebDriver set of commands? (i.e. can I do anything I might try in the Selenium IDE through Codeception?)
Does Codeception allow me to use the PageObject design pattern?
What kind of learning curve would I be facing without Codeception in terms of setting up my WebDriver server and test database? Does Codeception even make it that much easier?
There are Firefox plugins to convert 'Selenese' (html) test cases into PHPUnit or Codeception format. The PHPUnit test cases would need to be adapted to Peridot, but the Codeception converter is still in alpha and doesn't convert everything. I would rather not use these a great deal, but they would definitely help with the learning curve. How reliable are either one of these?
An official WebDriver plugin is definitely on the way for Peridot, but in the meantime, it's pretty easy to mix in WebDriver support using scopes.
We actually use WebDriver to demonstrate scopes here:
https://github.com/peridot-php/peridot-scope-example

What is the difference between behat, mink and selenium in php

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...

php kohana functional testing database environment

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

How can i apply or use selenium testing to php sites

I mostly buil sites in php/joomla/jquery. Someone told me to learn some unit testing system like selenium.
I want to know that , can i use that for php sites or only java based sites.
When i was learning j2ee then i find many testing systems but i don't know those work with php and joomla
Selenium can be used for PHP sites. Easiest path to getting started is (or was at one time, at least) to download the Seleneium IDE plugin for Firefox and use it to build tests. It can then export your tests as code into a number of different languages.
By the way, I don't consider Selenium a unit test tool. For unit testing in PHP, check out something like PHPunit.

Categories