Unit3 TDD CI
Unit3 TDD CI
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Write Your Tests First - How TDD works
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Write Your Tests First - How TDD works
3. Refactor: Then you go back and clean up any code or sins
you committed while trying to get the test to pass. Here
you are removing duplication and making sure everything is
lean, mean and as clear as possible.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Passing all the story’s acceptance criteria.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Test Driven Development
Source: http://agiledata.org/essays/tdd.html
Test-Driven Development
• In TDD, unit testing is carried out on the source code
directly.
Source: https://reqtest.com/testing-blog/tdd-and-atdd-an-overview-of-the-two-popular-methods-2/
Rules of Thumb
• Rule #1: Don’t write any new code until you first have a
failing test.
– not to write any more code than absolutely necessary.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Use the Tests to Deal with Complexity
• By writing your tests first and ensuring you have a failing test
before adding the new code, TDD helps you fight the sheer
amount of complexity you and your team are going to face
writing code every day.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Use the Tests to Deal with Complexity
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Other Reasons for Doing Test-First
With less code comes less complexity. And with a simpler design,
making changes and modifications becomes a lot easier.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Example
• Write the method name you would like to see on the Card
class that compares two cards and tells whether one is greater
than the other.
• Step 1
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Example
• Step 1:
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Example
• Step 2:
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Example
• Step 3: Refactor
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Test Driven Development
Source: https://www.guru99.com/test-driven-development.html
Step 1 - Write a Test
Source: https://www.guru99.com/test-driven-development.html
Step 2 - Write PasswordValidator code
• Test passes.
Source: https://www.guru99.com/test-driven-development.html
Step 3 - Refactor
• In method TestPasswordLength (), there is no need of
creating an instance of class PasswordValidator.
Source: https://www.guru99.com/test-driven-development.html
Step 4 - Refactor
• Test passes.
Source: https://www.guru99.com/test-driven-development.html
ACKNOWLEDGEMENT
• This presentation contains pictures, contents taken
from multiple sources, authors and sites.
Source: Internet
• Things we want to eliminate or at least manage.
• Production readiness - be able to demo our product to
anyone, anytime, anywhere.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
What Is Continuous Integration?
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
What Is Continuous Integration?
• Continuous integration is the act of continuously
taking changes developers make to their software
and integrating them all together continuously
throughout the day.
Work in Small Chunks
• Just like testing with TDD, integrating code is much easier
when done in the small.
• Merge your code early and often to avoid the pain of big
integrations.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
How Does It Work?
• A source code repository
– Store and version your software.
– Open source repositories like Git or Subversion.
• An automated build
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Establish a Check-in Process
1. Get latest source from the repository.
– Check out the latest build and start your work with a clean slate.
2. Make changes.
– Add the new functionality, fix the bug, or do whatever work needs
to be done.
3. Run tests
– Make sure the changes you made haven’t broken something else in
the code base, run all tests to make sure they all still pass.
4. Check for any more updates.
– If someone made some changes while you were doing your work.
5. Run tests again.
– Your changes work with whatever other changes others have made
6. Check-in.
– Everything builds. All the tests run.
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great Software', Shroff
Publishers and Distributers (SPD), (2016).
Create an Automated Build
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Create an Automated Build
Source: Jonathan Rasmusson, 'The Agile Samurai: How Agile Masters Deliver Great
Software', Shroff Publishers and Distributers (SPD), (2016).
Create an Automated Build
• The key to any build is automation—the less human
involvement, the better.
• You also want to keep your build fast, because you and your
team are going to be running constantly, many times per day
(under ten minutes is a good rule of thumb).
• If the language you are using doesn’t, you can usually create
your own with DOS bat files or Unix scripts.
Continuous Integration Tools
• Jenkins
- Test automation, configuration management, continuous
integration and continuous delivery
Source: https://anarsolutions.com/deploy-your-net-applications-azure-with-jenkins/
ACKNOWLEDGEMENT
• This presentation contains pictures, contents taken
from multiple sources, authors and sites.