For any developer to build quality software, proper testing is essential. At the latest edition of its explorer series meetups, this was the topic that Gapstars chose to tackle. It did so by sharing some of its best practices to testing software applications with practical examples by utilizing the popular Laravel PHP framework.
Kicking things off, we saw Jeroen Jochems – CTO of Temper take the stage. Tackling the topic of test-driven PHP, he opened by highlighting the advantages of testing. Granted, it’s a basic aspect of software development. Nevertheless, its importance cannot be understated as proper testing is essential to create quality software. As Jeroen explained, testing provides rapid feedback to guarantee quality code to build quality products. Additionally, it also brings a sense of professionalism in software engineering.
However, he emphasized that testing should be done while the code is being written to build the product. Whereas, many developers opt to conduct testing after a product is developed. Jeroen argued that this has several disadvantages.
Chief among them is that it results in happy path testing, which means only a portion of the code written is tested. Of course, this is assuming the developers do remember to test as it’s possible to forget about it entirely with this approach. Finally, he stressed that code that’s tested is ultimately readable code, which by extension makes the application easier to maintain well into the future.
Afterwards, Jeroen moved onto share some of the features that were readily available with the Laravel PHP framework. He did so through a series of Code Katas, which were small programming exercises. In doing so, Jeroen built a few basic applications. Through such exercises, he gave a first-hand look at how PHP developers can leverage the tools provided with Laravel and those using other languages an outline as to how proper testing can be one.
Following these Code Kata exercises, Jeroen gave a simple reminder to the audience. To any developer starting a new project, he said, “Start small. It helps you write clean code.” With that, he concluded his talk and walked off the stage. Soon afterwards, we saw Treasure Jayasinghe – Senior Software Engineer at Gapstars take the stage. Building on Jeroen’s introduction to software testing, Treasure jumped into a more advanced concept called Test Doubles.
To give an introduction to Test Doubles, Treasure turned to the definition by Martin Fowler, “A test double is a generic term for any case where you replace a production object for testing purposes.” If one were to simplify it further, it involves creating a duplicate of a component in the software. This duplicate component is then tested to see if it works properly.
Having laid the foundation, Treasure went onto explain that there are different flavours of Test Doubles that developers can utilize. They are known as Dummy Objects, Fake Objects, Stubs, Spies, and Mocks. If you’re a curious developer, looking to learn more about these test objects, you click here for a more in-depth explanation.
While explaining these concepts, Treasure too conducted his own set of Code Katas. Picking up from where Jeroen left off, we saw how Test Doubles can be implemented using Laravel. With that, Treasure concluded his talk. What followed was a Q&A session, which one could describe as nurturing as both speakers were quizzed by curious developers on different aspects of testing. After setting many doubts to rest, the latest edition of the Gapstars explorer series meetups came to an end.