Qafoo GmbH - passion for software quality ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Author: www-data :Date: Wed, 31 Oct 2018 10:07:55 +0100 :Copyright: All rights reserved ============================== Continuous & Automated Testing ============================== - Methods Of Teaching There are many different ways to teach topics of software developments. From recorded lectures to pair programming. Over the time we tried many of them with different customers and different topics. I want to provide you with an overview of what worked best for us for which topic. - Refactoring Singleton Usage to get Testable Code So your code base is littered with singletons and using them? Don't worry, you can start refactoring them out of your code base class by class and introduce increased testability at every step. This strategy is very simple to implement and the propability of breaking your code is very low, especially when you are becoming more experienced with this technique. - Five Tips to Improve Your Unit Testing After you got the hang of unit testing there is still so much space for improvement. In this post I want to share five tips with advanced testers I have seen to influence testing in the right direction. - Testing the Untestable A long time ago I wrote a blog post about Testing file uploads with PHP where I have used a CGI PHP binary and the PHP Testing Framework (short PHPT), which is still used to test PHP itself and PHP extensions. Since the whole topic appears to be still up-to-date, I would like to show a different approach how to test a fileupload in PHP in this post. This time we will use PHP's namespaces instead of a special PHP version to test code that utilizes internal functions. - Using Traits With PHPUnit As we already wrote that "Code Reuse By Inheritance" has lots of problems and we consider it a code smell. You should always aim to use Dependency Injection, most likely Constructor Injection. But with test cases in PHPUnit we cannot do this because we have no control about how and when our test cases are created. There are a similar problem in other frameworks, like we discussed in "Object Lifecycle Control". We also blogged about traits as a Code Smell, but let me show and explain why they might be fine to use in your test cases. - Database Fixture Setup in PHPUnit We already discussed when and how to reset a database between tests. But on top of that you often need some basic or more complex data to run the tests against. We discuss different variants and their respective trade-offs in this post… - Database Tests With PHPUnit Most of us do not use PHPUnit solely for Unit Tests but we also write Integration or Acceptance Tests with PHPUnit. One very common question then is how to interact with the database correctly in those tests. Let me show you the different options and their trade offs… - Introduction To Page Objects A while ago we wrote about writing acceptance tests (end-to-end tests) with Mink and PHPUnit. While this is a great set of tools for various applications such tests tend be susceptible to changes in the frontend. And the way they break is often hard to debug, too. Today I will introduce you to Page Objects which can solve some of these problems. - Outside-In Testing and the Adapter and Facade Patterns Outside-In Testing benefits a lot from the facade and adapter patterns, which will separate your code from third-party libraries and simplify the APIs of your system. - Common Bottlenecks in Performance Tests Most developers by now internalized that we should not invest time in optimizations before we know what happens exactly. This is true for optimizations in your PHP code but also for optimizations regarding your infrastructure. We should measure before we try to optimize and waste time. How can this be done?