GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing codeception.com — Functional Tests - Codeception Docs Guides
Testomatio - Test Management for Codeception Search💡 You are reading docs for latest Codeception 5. Read for 4.x
Functional TestsNow that we’ve written some acceptance tests, functional tests are almost the same, with one major difference: Functional tests don’t require a web server. Under the hood, Codeception uses Symfony’s BrowserKit to “send” requests to your app. So there’s no real HTTP request made, but rather a BrowserKit Request object with the required properties is passed to your framework’s (front-)controller. As a first step, you need to enable Codeception’s module for your framework in All of Codeception’s framework modules share the same interface, and thus your tests are not bound to any one of them. This is a sample functional test: As you see, the syntax is the same for functional and acceptance tests. LimitationsFunctional tests are usually much faster than acceptance tests. But functional tests are less stable as they run Codeception
and the application in one environment. If your application was not designed to run in long lived processes (e.g.
if you use the Headers, Cookies, SessionsOne of the common issues with functional tests is the use of PHP functions that deal with headers, sessions and cookies.
As you may already know, the External URLsFunctional tests cannot access external URLs, just URLs within your project. You can use PhpBrowser to open external URLs. Shared MemoryIn functional testing, unlike running the application the traditional way, the PHP application does not stop after it has finished processing a request. Since all requests are run in one memory container, they are not isolated. So if you see that your tests are mysteriously failing when they shouldn’t - try to execute a single test. This will show if the tests were failing because they weren’t isolated during the run. Keep your memory clean, avoid memory leaks and clean global and static variables. Enabling Framework ModulesYou have a functional testing suite in the SymfonyTo perform Symfony integration you just need to include the Symfony module into your test suite. If you also use Doctrine,
don’t forget to include it too. To make the Doctrine module connect using the By default this module will search for AppKernel in the The module uses the Symfony Profiler to provide additional information and assertions. LaravelThe Laravel module is included and requires no configuration: Yii2Yii2 tests are included in Basic and Advanced application templates. Follow the Yii2 guides to start. LaminasLaminas tests can be executed with enabling a corresponding module.
Phalcon 5The Writing Functional TestsFunctional tests are written in the same manner as Acceptance Tests
with the Therefore we can open a web page with We can click links to open web pages: We can submit forms as well: And do assertions: Framework modules also contain additional methods to access framework internals. For instance, Laravel, Phalcon,
and Yii2 modules have a Take a look at the complete reference for the module you are using. Most of its methods are common to all modules but some of them are unique. You can also access framework globals inside a test or access the dependency injection container
inside the Also check all available Public Properties of the used modules to get full access to their data. Error ReportingBy default Codeception uses the
ConclusionFunctional tests are great if you are using powerful frameworks. By using functional tests you can access and manipulate their internal state. This makes your tests shorter and faster. In other cases, if you don’t use frameworks there is no practical reason to write functional tests. If you are using a framework other than the ones listed here, create a module for it and share it with the community.
Don't know how to write tests on your own? We will build or improve them for you.
Request a quote for official
enterprise
support or trainings
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |