It’s great to experiment! How can we experiment safely? Testing is the first step in creating a safe development cycle and supporting continuous delivery. The earlier you discover issues, the earlier (and cheaper) they are to fix.
Whether run from the IDE or triggered by git, unit tests live on the front lines and are the first place in which major issues can be identified during development. Unlike integration tests or UI tests, Unit tests operate on just one function, making them a lot easier to debug.
On the 23rd July, Nintex Promapp hosted a workshop on Unit Testing. Nintex has over 12,000 unit tests that are run against every release! After a short introduction to Nintex and a description of what the company does, Gareth Maria gave an enlightening talk about how to write testable code and the SOLID principles:
• S – Single Responsibility Principle
An object or function should do exactly one thing and do it well. Focusing on one task allows tests to focus on that task, making test-writing straightforward and obvious.
• O – Open/Closed Principle
Code should be open for extension, closed for modification. When new functionality is needed, it’s tempting to change existing functions. However, not only does this lead to eventual bloat, it also makes testing harder. Rather than making modifications, testable code extends what’s already there, adding functionality without changing existing behaviour.
• L – Liskov Substitution Principle
Anytime a class depends on a second class, instances of the second class should be interchangeable with no visible change in behaviour. When testing, this allows dependencies to be replaced by ‘mock’ objects. • I – Interface Segregation Principle Changing an interface has ripple effects on every class that implements it. Keeping interfaces as small as possible minimises these knock-on effects, simplifying development and reducing the risk of breaking things. •
D – Dependency Inversion Principle
High level code should not rely on the implementation of low-level code. A good analogy Gareth used was describing a car: “If I want an electric car, ideally I would swap the engines out without having to replace anything else.”
Following this introduction, we went through various problems. Writing unit tests and refactoring code to make it more testable. All the while, Nintex staff floated between groups, giving students pointers on what they were doing.
Nintex provides a platform for process management and automation. Making it easy to visually plan, map, and manage business processes. This allows managers to identify the processes best suited for automation and optimize procedures through leveraging data. Nintex Promapp builds the business process management (BPM) software side of this.