Clean Code Cheat Sheet Page 4

ADVERTISEMENT

Continuous Integration
ATDD, TDD cycle
Pre-Commit Check
+
Write acceptance criteria for user story
Define examples
Write acceptance test skeleton
Run all unit and acceptance tests covering currently worked on code prior to
The whole team defines acceptance criteria for
The whole team defines examples for acceptance
Map the examples into an empty specification/test in your acceptance
committing to the source code repository.
user stories.
criteria used to show that code works.
test framework (Gherkin, MSpec classes and It statements …)
Post-Commit Check
+
Run all unit and acceptance tests on every commit to the version control
You need to build up knowledge to implement the
system on the continuous integration server.
You have enough knowledge to
acceptance test.
implement the acceptance test.
Communicate Failed Integration to Whole Team
+
Whenever a stage on the continuous integration server fails, notify whole
Make an initial design
Explore design
team in order to get blocking situation resolved as soon as possible.
Roughly design how you want to implement the new functionality,
Implement a Spike to gather enough knowledge
Build Staging
+
especially the interface for your acceptance test (how to call and verify
so you can design a possible solution.
functionality).
Split the complete continuous integration workflow into individual stages to
reduce feedback time.
Automatically Build an Installer for Test System
+
Refactor
Automatically build an installer as often as possible to test software on a
Refactor existing code to simplify introduction of new functionality. Run
test system (for manual tests, or tests with real hardware).
all tests to keep code working.
Continuous Deployment
+
Install the system to a test environment on every commit or manual
Succeeded, not all
Write an acceptance test
request. Deployment to production environment is automated, too.
acceptance tests
Add arrange, act and assert parts to the acceptance test skeleton (Given,
Test Pyramid
implemented yet
When, Then or Establish, Because, It …).
Succeeded and all
examples tested
Run acceptance test
Failed
Make error reason obvious
The failing test should state what went wrong so you don’t have to
debug the code.
You have no class
design idea
You have a class
Succeeded,
design idea
code clean,
Spike a solution
Make initial or update class design
TO DO list
Design how you want to implement the new
empty
Implement a Spike to get the acceptance test
running so that you get an initial design.
functionality.
Constraint Test = Test for non-functional requirements.
Do per class
TO DO list
Bibliography
 Add missing test when you think of one
Test Driven Development: By Example by Kent Beck
 Remove test when written
ATDD by Example: A Practical Guide to Acceptance Test-Driven
Development by Markus Gärtner
We write the TO DO list into the same file as the
unit test with // TODO:
Write a test
The Art of Unit testing by Roy Osherove
Add a minimal test or make a minimal change to
xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros
Pick test:
an existing test (< 10 minutes).
1) Prove that the code is making a hard coded
assumption.
2) Prove that something is wrong.
3) Prove that something is missing.
Succeeded,
code clean,
Run test
TO DO list
not empty
Failed
Succeeded
Make error reason obvious
Failed
Run all tests
The failing test should state what went wrong so
you don’t have to debug the code.
Clean up code
Write code
Apply clean code guidelines. Redesign classes as
Succeeded,
Write as little code as possible to make the test
Legend:
needed. (< 10 minutes).
code not clean
pass.
DO
+
DON’T
Urs Enzler June 2013 V2.1

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 4