Apr 10, 2023
In Lytvynov Production we love testing and we use Codeception a lot.
Codeception is a modern and powerful testing framework for PHP applications. It provides a flexible and intuitive syntax for writing functional, acceptance, and unit tests. Codeception can be used to test a wide range of applications, including web applications, APIs, and command-line applications.
One of the main advantages of Codeception is its modular architecture, which allows developers to easily extend and customize the framework to suit their specific testing needs. It also provides built-in support for popular testing frameworks such as PHPUnit, Selenium WebDriver, and REST API testing tools like Guzzle.
Codeception also provides a clear and comprehensive reporting system that makes it easy to identify and fix bugs and issues during the testing process. Overall, Codeception is a great choice for developers looking for a robust and flexible testing framework for PHP applications.
Acceptance tests, also known as functional tests, are a type of software testing that evaluates the behavior of a software application from the user's perspective. Acceptance tests are typically performed to ensure that the application meets the requirements and expectations of its end-users.
Unlike unit tests, which focus on testing individual functions or methods in isolation, acceptance tests evaluate the entire application, including its user interface, user interactions, and data flows. Acceptance tests are typically performed on a fully functional version of the application, often referred to as a "build," that closely resembles the final product.
Acceptance tests are generally automated using testing frameworks such as Codeception, which provide a set of tools for simulating user interactions with the application and verifying that the application behaves as expected. This helps to ensure that the application is reliable, efficient, and user-friendly, and that it meets the needs of its intended audience.
Let's say we want to login on our login page, so we need to creae a LoginCest.
We can do it manually or generate with a command
Here is the code
By default we have PhpBrowser, it allows us to run tests and that's enough if you need not see all effects related with front changes.
In case you would like to use more powerfull tull - Selenium - you need to install Web Driver.
PhpWebDriver is a PHP library that provides a simple and easy-to-use interface for automating web browsers using the WebDriver protocol. WebDriver is a protocol that defines a standardized way to interact with web browsers programmatically, allowing developers to automate web testing, scraping, and other browser-based tasks.
Using PhpWebDriver, developers can write PHP scripts that simulate user interactions with a web page, such as clicking buttons, filling out forms, and navigating between pages. PhpWebDriver supports a wide range of web browsers, including Chrome, Firefox, Safari, and Microsoft Edge.
And your config
Now is the most tricky part - run selenium.
You can run it locally and in this case the documentation is pretty good, jump to Local Seput (Selenium Server)
Or you can add selenium locally to your docker.
Selenium is an open-source testing framework that allows developers to automate web browsers and perform browser-based testing. It provides a suite of tools and libraries for interacting with web browsers in various programming languages, including Java, Python, and PHP. Selenium is widely used in the software development industry to ensure the quality and reliability of web applications. It is often used in conjunction with other testing tools, such as Codeception, to create comprehensive test suites that cover all aspects of an application's functionality.
docker-compose with selenium/standalone-chrome:latest example.
The result you ll see in your terminal
In conclusion, if you are interested in learning more about our testing practices and how we can help ensure the success of your project, we invite you to visit our testing page at https://lytvynov-production.com/testing. There, you can find more information about our testing services, tools, and methodologies, as well as examples of our past projects and success stories.