Two Joomla! Code Sprints: Madrid and Montabaur
Every now and then the Joomla project organizes a Code Sprint. The purpose of a sprint is to improve a specific area of the Joomla ecosystem, this can be the code, documentation or something else. During a sprint a group of people with expertise in this specific area are brought together in one place. Not online but offline, real life meetings. Nothing beats a face-to-face meeting if you want to make things happen.
Madrid
On the 11th and 12th of October there was a Code Style Sprint in Madrid, Spain. The goal of this sprint was to clean up the Joomla code to adhere to the code style that we have set for ourselves. Clean and consistent code makes for code that is easier to maintain, less prone to bugs and we can enforce clean code for new contributions to ensure the code stays clean. We cannot enforce clean code when our own code is not clean.
With a group of 6 people we sat down and decided the goal was to go through every file in the Joomla code and check it for following the code style rules. A bold goal knowing that Joomla has a large codebase, but we were confident that it could be done.
We locked ourselves in a basement (quite literally except for the lock) and went to work. Not sure if the lack of daylight influenced our results but after emerging from our dwelling we realized we did a good part of the codebase. To celebrate our victory, to keep with our new tradition, we went out to eat in a basement. We should preserve our new found magic.
The next two days we continued our quest to clean up every file in the codebase. As time progressed, of which we had no notion in our new found workplace, we ploughed through the files. Slowly but steadily and with every cleaned file we felt more excited. Keeping track of every folder that had to be done and ticking off once done the list shrunk in front of our ever shrinking eyes. Glued to the screen to get to the finish line.
As the final day drew to a close, not even leaving our basement anymore, pizza was ordered in, we started to see the light. The last files were being checked and the first pull requests were being committed. The time had come to climb out of the basement of inconsistent code and into the light of consistent code and see what our magic has done. The numbers impressed us all. Have a look at the graph. Be aware, this graph is not only our work but also that of other people who help Joomla on a regular basis.
We were all pretty stoked for having done so much work despite the struggles with Git. We all had times we wanted to throw some sort of equipment, usually the laptop, out of the window because of Git. With the help of Roberto and perseverance we withstood the lashes received by Git. We came, we saw and we conquered.
I would like to thank the following people for participating in the code style sprint:
It was a great pleasure to work with such professionals and I feel privileged being able to help out the Joomla Project.
Furthermore I would like to thank all the organisers of the JoomlaDay Madrid Spain 2014, an event that was taking place during the same weekend and in the same city. Especially Alberto Gomez-chacon, Pedro Vidal and Irene López for their help with the logistics of the Code Sprint.
Montabaur
Every release that is put out by Joomla needs to be a stable and well-tested release. Despite the efforts of the Joomla Bug Squad team and automated testing, we could use more and better testing. A lot can be gained from more and better automated testing. An initiative was started by Robert Deutz to organise a code testing sprint.
On Wednesday 15th of October the time had come for a code testing sprint being held in Montabaur Germany. A total of eight people came together to meet up with Sebastian Bergmann, author of PHPUnit, to improve our knowledge on writing unit tests and work on the Joomla test suite. To make sure nobody would wander off, we were stationed on top of a mountain. A walk down would mean a long walk up again.
We started with an introduction to unit testing by Sebastian. Not only are there the unit tests but also the system tests, in layman's terms a unit test is a test of the code (the thing you don't see as a user) and a system test is a test of the interface (the thing you do see as a user). To maintain both these kind of tests there is a unit test working group and a system tests working group. Later that day we made a list of all topics we would like to see covered over the next 3 days and work through them.
Writing tests is no easy task, we were all thoroughly tested to the best of our abilities. We found out that it is not so difficult to write a test, but to write a meaningful test takes skill. As the international Pizza, Bugs and Fun fell on the same day as our sprint was going on, we survived that day on pizza as well, and worked till late at night. Here is a short overview of things everybody has worked on, this is not a complete list but just to give you an idea of the areas we worked on.
Michael Babker
- Improved the basis of the Joomla unit tests
- Reorganized some of the "supporting" files (DDL schema & files holding dummy content for the tests) in the folder structure for a more logical organization
- Reviewed database tests and many tests covering classes in the libraries/cms and modified them to use a different test assertion more specific to what was actually being tested
- Restructured tests for the JDocument classes to be more proper unit tests instead of functional tests Proposed refactoring of \Joomla\Language\Text class in the Framework to not use any static methods and restructured test cases for the class for better unit testing practices
Viktor Vogel
- Created wrapper classes to get rid of static methods. For details see this pull request: https://github.com/joomla/joomla-cms/pull/4717
Robert Deutz
- Improved code coverage for JArchive, 7% more code coverage
- Codeception setup (this is still work in progress)
- Testing documentation
David Jardin
- Improved code coverage for JModel legacy classes from 9% to 40%
- Checked exisiting documentation, added docs for "Best Practices" and "Testing with Database connection"
- Fixed a bug related to rounding issues in the current test suite
Puneet Kala
- Refactored code and removed the unwanted/unmaintained Selenium RC tests
- Identified two issues in Joomla staging branch which were present due to a wrong commit
- Worked on the Codeception framework to make tests run in parallel
Niels Braczek
- A considerable cleanup. About 700 tests were incomplete or risky, as stated by PHPUnit run in strict mode. At the end of the sprint, all of them were either removed or supplied with meaningful assertions.
- Worked on removing an ancient method of prefixing variables with an underscore to indicate private variables. How he did get rid of the underscore while staying backward compatible may be subject of a separate article.
Javier Gomez
- Worked on creating tests for JLayout
- Worked on the Codeception framework to make tests run in parallel
Roland Dalmulder
- Worked on creating tests for JLayout
- Worked on creating tests for multi-language
More than just Joomla
Not only have we been improving Joomla but also other open source projects as we identiefied bugs in:
- PHPUnit
- de-legacy-fy
- PHP 7
Moving forward
To ensure the work on our code testing doesn't stop here we have a created a document which contains the links to different documentation pages that needs reviewing. This will help us to get other people engaged in testing. Furthermore we have laid out plans to continue working on the unit tests and clean them up so we can have an up-to-date set of tests that can be worked on to improve them.
Care to help?
If you are interested in helping us out improving the test base feel free to contact one of the working groups. We will be happy to have you on board.
This event would not have been possible without the sponsoring of 1und1.
Some articles published on the Joomla Community Magazine represent the personal opinion or experience of the Author on the specific topic and might not be aligned to the official position of the Joomla Project
By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/
Comments