Google Summer of Code
#GSoC Empowering Tomorrow's Coders: Igniting, Innovating, and Inspiring Mauticians of the Future with Google Summer of Code.
Week 3-4: End-to-end test suite for Mautic- Putting Mautic to Test
Hi everyone,
Welcome back for another update on my Google Summer of Code project! This week, things got real! After setting up the test environment and getting comfortable with Codeception, it was time to put that knowledge to the test (pun intended!).
Testing with WebDriver
Since Mautic heavily relies on JavaScript and AJAX, we are using the webdriver module for our test suite and in the last blog we discussed how to configure it.
PhpBrowser does not execute javascript, if we want to test the effects of client side code, we must use the WebDriver module. Webdriver executes tests in a real browser environment, such as Chrome or Firefox. This approach allows JavaScript code to be executed on web pages, allowing for more precise UI testing. However, there are some drawbacks. WebDriver requires additional infrastructure, either Selenium or a headless browser. Also, the execution speed of these tests is comparatively slower than that of tests executed through PhpBrowser, due to the complete web page loading process.
Ensuring Reliability: Wait Strategies
Reliable tests rely on web elements being loaded before interacting with them. We can use various Codeception wait strategies like waitForElementVisible
and waitForText
. Choosing the right strategy depends on the specific element and its behaviour on the page.
What Happens if a Test Fails?
Screenshots of the browser window and the entire HTML source code of the page are captured and saved in the “tests/_output” directory.
Focusing on Contacts
After discussions with my mentors, we decided to prioritize testing functionalities related to contacts. Over the past two weeks, I've been writing tests that cover both CRUD (Create, Read, Update, Delete) operations and batch actions for managing contacts.
Maintaining Data Integrity: db Module
To ensure test isolation and data integrity, we're using the db module for data management. While testing, your actions may change the data on the site. Tests will fail if trying to create or update the same data twice. For example, if a test creates a contact, another test trying to create the same contact with the same information would fail. To avoid this problem, your database should be repopulated for each test. The db module helps maintain a clean slate for each test by resetting the database to a predefined state.
Here's a quick guide to implementing the db module:
1. Install the module:
composer require --dev codeception/module-db
2. Create an SQL dump of your database:
mysqldump -u [uname] -p db_name > tests/_data/dump.sql
3. Configure your acceptance.suite.yml file to utilize the db module.
Next week’s focus
- Expanding test coverage to include additional Mautic features.
- Refining existing tests based on mentor feedback.
- Organizing tests and implementing the Page Object Model (POM) for better maintainability.
Your Feedback Matters!
Feel free to leave any comments or questions below. I'm always looking for ways to learn and improve my testing approach.
See you next week for another update!
Report inappropriate content
Is this content inappropriate?
0 comments
Loading comments ...
Add your comment
Sign in with your account or sign up to add your comment.
Loading comments ...