<
Neerav Mehta
Founder & CEO
In our previous blog post, we made a pretty big claim that Drupal 7 unit testing is broken. You probably knew that already but you know the importance of testing a big Drupal project as well. So like us, you started using Behat and Selenium for functional and user acceptance testing. It worked well for a while but now there are so many test scenarios that you are finding it difficult to maintain all of them. To make it worse, your test suite takes hours and hours to complete. But do not despair! Here comes integration test to your rescue.
Yes, we do. But if you try to implement all your test cases on a tool such as Behat, you will quickly find that your test suite is exploding and is becoming unmanageable. Also functional tests are extremely slow, so something that can be tested using integration tests in 15 minutes will take 5 hours to be tested using functional tests. Remember, quicker feedback is always better!
If you are using Drupal 7, I find it hard to believe that you have unit tests that cover all of your custom code. But even if you do (I am extremely extremely impressed if you do! Please write to me how? And yes, I intentionally wrote "extremely" twice.), integration testing provides some advantages over units tests:
Yes and no. Writing tests does take time. In fact, some times, it takes more time to write a test in Drupal than to create the functionality. That's because you can create a functionality in Drupal using the UI but writing tests requires writing code. So ask your developer whether he can write bug-free code 100% of the time. If he says yes, then do not hire him because he is lying or he has no experience of writing a big piece of software. On a more serious note, yes, cost of the project will increase if you write tests when you are getting bug-free code 100% of the time. But I have never seen this happen in a big project. Usually what happens is that if you do not have tests, then after a point of time, it will become exceedingly difficult to push new features to production because adding more functionality will break old functionality, or worse, you will find older piece of functionality breaking on the live site after you have pushed new functionality to production. So here comes the next question.
Here are some cases where we have seen integration testing to be worth the effort:
On the other hand, if you are a small or medium sized business, with more or less a static site and where a few bugs here and there are not bothering you much, then don't worry about automated testing. You can skip the rest of this blog post.
Till now, it didn't. Now it does. We created this framework, named "Red Test", to solve the exact problems that I have mentioned in this blog post. We have been using it since over a year now and it's already in its fourth version. We are making it open-source so that other developers and agencies can benefit by using it to maintain big Drupal sites. If you can't wait to get your hands on it, then go to the next article explaining how to install Red Test on your system. Others, read on!
Red Test is an automated integration testing framework based on PHPUnit and specifically designed for Drupal. It understands Drupal. This means that there are a lot of things it can do without you having to tell it. It knows about the node table, the users table, the forms, the entities and the likes. It knows how to create new nodes and how to even test them. This means that your test code gets reduced drastically. Here are a few things we had in mind when we created Red Test:
So are you excited about Red Test? In the next post, you will learn how to install Red Test.
Neerav Mehta
Neerav Mehta is the Founder & CEO of Red Crackle. With sterling qualities, Neerav’s technological acumen is firing a generation of progressive companies on the digital path. With an undergraduate degree in Electrical Engineering from India's most prestigious institution IIT Bombay and having spent seven years developing and contributing to the launch of AMD's innovative line of computer products, Neerav founded Red Crackle where he is lauded for his dynamic and innovative genius.
Let’s get you started!