1. Testing in Symfony
Roughly speaking, there are two types of test. Unit testing allows you
to test the input and output of specific functions. Functional testing
allows you to command a “browser” where you browse to pages on your
site, click links, fill out forms and assert that you see certain things
on the page.
1.1. Unit Tests
Unit tests are used to test your “business logic”, which should live in
classes that are independent of Symfony. For that reason, Symfony
doesn't really have an opinion on what tools you use for unit testing.
However, the most popular tools are PhpUnit and PhpSpec.
1.2. Functional Tests
Creating really good functional tests can be tough so some developers
skip these completely. Don't skip the functional tests! By defining some
simple functional tests, you can quickly spot any big errors before you
deploy them:
1.3. Testing JavaScript Functionality
The built-in functional testing client is great, but it can't be used to
test any JavaScript behavior on your pages. If you need to test this,
consider using the Mink or Selenium.
The above text is based on official Symfony documentation found here: http://symfony.com/doc/current/best_practices/tests.html
The above text is based on official Symfony documentation found here: http://symfony.com/doc/current/best_practices/tests.html
2. Acceptance testing
Acceptance testing can be performed by a non-technical person. That
person can be your tester, manager or even client. If you are developing
a web-application (and probably you are) the tester needs nothing more
than a web browser to check that your site works correctly. You can
reproduce a AcceptanceTester's actions in scenarios and run them
automatically after each site change. Codeception keeps tests clean and simple, as if they were recorded from the words of AcceptanceTester.
2.1. Functional vs Acceptance testing
Acceptance tests are front-end only and you are testing
whether you see the correct UI elements. This type of test never
explicitly checks the database with a direct call. Think of it as only
testing what an end-user would be able to see by clicking around in a
browser.
Functional tests are similar to acceptance tests but they do check the database explicitly, something like $I→seeInDatabase() or $I→seeRecord(). Functional tests generally use a DOM parser instead of a browser (or phantomJS) like acceptance tests do – this is why JS is best left to acceptance tests.
Functional tests are similar to acceptance tests but they do check the database explicitly, something like $I→seeInDatabase() or $I→seeRecord(). Functional tests generally use a DOM parser instead of a browser (or phantomJS) like acceptance tests do – this is why JS is best left to acceptance tests.
3. All in one: Codeception
With Codeception you can run unit, functional and acceptance tests..
Why should I use Codeception instead of PHPUnit?
Being the most popular unit testing framework PHPUnit has very limited features for functional testing with Selenium or other backends. Codeception is PHPUnit on steroids. Everything you need for testing is built-in and works just out of the box. No more pain in configuring Selenium, data cleanup, writing XPaths, and fixtures.
Q: It looks just like Behat
Unlike Behat, Codeception tests are written in PHP. Thus, they are more flexible and easy in writing. Also you can use variables and operators, CSS and XPath locators in your tests. These features allow you to build a solid test automation platform for testing your web application. Codeception tests are simple and readable for your developers, managers, and QA team.
Q: We are planning to use Selenium IDE. Why Codeception?
Codeception works great with Selenium. But with Codeception you can write your tests in PHP. The main reason is: Selenium IDE tests are tightly bound to XPath locators. If you ever change anything in layout tests will fall. Codeception locators are more stable. You can use names, labels, button names and CSS to match elements on page. It's much easier to support the Codeception test then Selenium's one. Selenium just can't clean data between tests, can't check database values, or generate code coverage reports.
Q: Is Codeception a tool for testing legacy projects?
Sure you can use Codeception for black-box testing of your legacy application. But in the same manner you can start testing modern web application as well. With modules that integrates with all popular PHP frameworks you can start writing functional tests in seconds. Unit tests? Write them as you do in PHPUnit with some enhancement. Codeception keeps your tests in one place, makes them structured and readable.
Source: http://codeception.com/
Why should I use Codeception instead of PHPUnit?
Being the most popular unit testing framework PHPUnit has very limited features for functional testing with Selenium or other backends. Codeception is PHPUnit on steroids. Everything you need for testing is built-in and works just out of the box. No more pain in configuring Selenium, data cleanup, writing XPaths, and fixtures.
Q: It looks just like Behat
Unlike Behat, Codeception tests are written in PHP. Thus, they are more flexible and easy in writing. Also you can use variables and operators, CSS and XPath locators in your tests. These features allow you to build a solid test automation platform for testing your web application. Codeception tests are simple and readable for your developers, managers, and QA team.
Q: We are planning to use Selenium IDE. Why Codeception?
Codeception works great with Selenium. But with Codeception you can write your tests in PHP. The main reason is: Selenium IDE tests are tightly bound to XPath locators. If you ever change anything in layout tests will fall. Codeception locators are more stable. You can use names, labels, button names and CSS to match elements on page. It's much easier to support the Codeception test then Selenium's one. Selenium just can't clean data between tests, can't check database values, or generate code coverage reports.
Q: Is Codeception a tool for testing legacy projects?
Sure you can use Codeception for black-box testing of your legacy application. But in the same manner you can start testing modern web application as well. With modules that integrates with all popular PHP frameworks you can start writing functional tests in seconds. Unit tests? Write them as you do in PHPUnit with some enhancement. Codeception keeps your tests in one place, makes them structured and readable.
Source: http://codeception.com/
No comments:
Post a Comment