
What are the components that help teams to build quality into their outcomes?
The main goal is to create a baseline that developers could follow and be in a quality level that is well defined and measurable. The main parts to focus on are:
- Testing
- Code reviews
- Static analysis
- Health monitoring: availability, resilience, etc’.
Tests
Why you wish to invest in it?
- It should be FAST and easy – The tests should run fast in order to encourage developers to use them constantly during the development process. Later, in your CI/CD system that automation of tests (small ones) should run as fast as possible (minutes not hours) so you can move quickly to the next phase. It’s worth to mention that you don’t need to run ALL the tests here. Some part of tests (smoke tests or other term you like) should give you enough confidence to move forward with the pull request or the merge of the change into your main branch.
- Stable – The test doesn’t break often. You wish to minimize the false-positive ratio as much as you can. This is why you need ‘small’ tests that are encapsulated and give you a clear sign on what is working (or not).
- Easy to read, maintain, run and understand.
- Catches Bugs! When a test fails it’s most probably a bug. You wish to avoid ‘flaky’ tests as it’s one of the productivity breakers.
- Automated – If you are running tests in a manual phase it’s ok for the ‘last mile’ but not for all the other important cases. You CI/CD system should run your test each time a change it being made to the codebase.
How to improve your tests?
- Have a good coverage of your code: a) ~70% with unit tests which are ‘small’ tests that run fast and encapsulated. It might be that the right number for your needs is higher, so go for it. The idea here is to think about the ROI and make sure the tests are helpful. b) 20% for integration tests c) 10% for UI (or end-to-end) tests.
- ROI – A good coverage to effort ratio.
- Make sure you have: a) Unit tests b) Integration tests c) Functional tests / End-to-end tests d) Performance test
- It’s all automated and part of your build process.
- You can also divide the world of ‘test type’ to S/M/L.
- When you have an issue with production → You creating a test to cover it in the future.
- Learn from your (and others!) history. Build a process of debriefing after each time something happened (or almost happened) and create a test that covers this case for the future.
- You can test in production but think carefully if it’s the right thing to do for your specific case. Can you use Mocks, Stubs?
Code Reviews
Code review is a process that extremely helpful to improve developers and catch critical bugs or ‘logic complexity’ that will explode in the future. If there is only one thing you wish to take from these ideas – take this one and create a process of code review around each change in your code.
Benefits of a code review process
- Accidental errors (e.g., typos) as well as structural errors (e.g., dead code, logic or algorithm bugs, performance or architecture concerns) are often much easier to spot for critical reviewers.
- Legible code is more reusable, bug-free, and future-proof.
- Committers are motivated by the notion of a viewer who will look over the change request: the committer tends to clean up loose ends, consolidate TODOs, and improve the commit.
- Sharing knowledge: Reviewers may possess knowledge about programming techniques or the code base that can help improve or consolidate the change.
- Consistency in a code base makes code easier to read and understand.
Static Analysis
This is one of the easiest things to start with. If you have a system around continues integration there are many options (=plug-ins) to use tools for static analysis. Why you wish to do it? Low Effort → High ROI
More benefits form using static analysis tools
- Helps identify potential software issues during development.
- Helps to detect code that needs: simplification, readability, testability etc’.
- It also improves communication in the development team and helps to produce high quality code.
What are the (main) options?
- You can use a SAAS option like Sonarsource
- SpotBugs – part of your build/dev process.
- Many other options to use linting extensions/plug-in so you will catch many issues during development time.
Few suggestions for FrontEnd Developers
- Mountebank – Mocking over the wire
- Percy.io – Solving visual testing across design, development, and deployment.
- testim.io – UI testing with ML.
- Jest – unit and integration tests and TestCafe for UI tests.
- A testing structure – Mocha (Full tutorial), Jasmine, Jest, Cucumber
- Provide assertions functions – Chai, Jasmine, Jest, Unexpected
- Generate, display, and watch test results – Mocha, Jasmine, Jest, Karma
- Generate and compare snapshots of component and data structures to make sure changes from previous runs are intended – Jest, Ava
- Provide mocks, spies, and stubs – Sinon, Jasmine, enzyme, Jest, testdouble
- Generate code coverage reports – Istanbul, Jest, Blanket
- Katalon Studio – a full IDE for UI tests.
- Provide a browser or browser-like environment with a control on their scenarios execution – Protractor, Nightwatch, Phantom, Casper
Last but not least, it’s useful to remember that in order to have quality you should not focus on the tools and frameworks but about the culture and the people. As Jeff said in the past:
“High standards are contagious. Bring a new person onto a high standards team, and they’ll quickly adapt. The opposite is also true.”
