Giter Site home page Giter Site logo

testing_legacy_code's Introduction

Testing legacy code: Hard-wired dependencies

Code related to my Testing legacy code: Hard-wired dependencies blog post

What is it about?

Provides an example of existing code that needs to be unit tested. But there is one rule:

We can't change any existing code if not covered by tests. The only exception is if we need to change the code to add unit tests, but in this case, just automated refactorings (via IDE) are allowed.

Although this is a very small piece of code, it has a lot of the problems that we find in legacy code.

Details

If you want to give it a go, the starting point is TripService_Original.java. Try unit testing it following the rule above.

My solution was TripServiceTest.java and TripSerivce.java

testing_legacy_code's People

Contributors

sandromancuso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

testing_legacy_code's Issues

Not the same as during GeeCon

hi

I attended your talk during GeeCon i really liked it. I wanted to use this project as a reference on refactoring legacy code but it seems that:

  1. the solution here (https://github.com/sandromancuso/testing_legacy_code/blob/master/src/main/java/org/craftedsw/harddependencies/trip/TripService.java) is not the same as to the one you showed during your talk (asfair at GeeCon you were mocking TripDao and inject that mock into TripService in unit tests)
  2. I wish the commit history here would reflect all single steps you did to refactor the code - just like you did during your talk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.