Skip to content
  • Blog
  • Events
  • Help
  • Careers
  • Contact
New Signature
  • About
      • Company

        New Signature has built a record of leadership by delivering exceptional technology and web solutions.

        View Company

      • Awards

        As a company, we are regularly recognized within the IT industry as well as the communities we serve.

        View All Awards
      • News

        Learn about the newest company announcements, technologies, and products at New Signature.

        View News

      • Partners

        New Signature works with a number of outstanding technology companies to deliver the best experiences to our customers.

        View Partners
      • Leadership

        New Signature's executive team includes proven leaders from the most innovative and fast-growing technology fields.

        View Leadership

      • Industries

        Our solutions are tailored to empower organizations across a wide range
        of industries.

        View Industry Experience
    Close
  • Solutions
      • Intelligent Enterprise
        Solutions

        Going Digital
        Unleash cloud capability, deliver change and compete at speed with a Microsoft digital operating model, enabling you to work more efficiently as you transform your IT environment. Learn More

      • Featured Solution

        Secure Cloud
        In a world of constant threat, ensuring that your underlying cloud platform is protected is the first step on your organization’s journey towards a secure, compliant operating environment. Learn More
      • Intelligent Workplace
        Solutions

      • Secure Workplace

        Work Anywhere

        Endpoint Health

        Identity Health

        Teamwork Support



        VIEW WORKPLACE SOLUTIONS
      • Intelligent Cloud
        Solutions

      • App Factory

        Azure Accelerator

        Azure Launchpad

        Azure Launchpad for DevOps

        Application Health

        Platform Health

        VIEW ClOUD SOLUTIONS
    Close
  • Services
      • Begin your journey towards becoming a digital business with NS:GO, our unique end-to-end framework based on the Microsoft Cloud Adoption Framework.

        NS:GO DIGITAL OPERATING MODEL
      • Intelligent Enterprise

      • Consulting

        We go beyond just technology to help your organization understand how digital can help you uniquely differentiate and better serve your employees and customers.

        VIEW ENTERPRISE SERVICES
      • Intelligent Workplace

        • Identity

          Identity is your new first-line-of-defense. It’s vital to your users and clients that your identity platform is properly configured and secured.

          Endpoint

          Whether your devices are on-premises or remote, personal or business-owned, we can ensure they are properly managed and protected.

          Teamwork

          Today’s workforce is collaborating than ever before.  We can empower your current teams with tomorrow’s progressive technologies.

          VIEW WORKPLACE SERVICES
        • Intelligent Cloud

          • Platform

            The cloud is no longer some future-state. It’s the here and now. Adopting a cloud-first platform is one of the best ways to maintain a future-proofed competitive advantage.

            Applications

            We build cloud-native apps and modernize legacy systems with the power of Azure to give your organization a competitive edge.

            Data

            We can help your organization create secure, scalable data platforms to deliver simpler and more sophisticated insights to your business.

            VIEW CLOUD SERVICES
        Close
      • Client Stories
          • Case Studies

            Browse a comprehensive list of companies who have created successful partnerships and experienced transformative solutions with New Signature.

            View All Case Studies

          • Featured Case Study TalkTalk Modern Workplace

            New Signature worked with TalkTalk to define a new Modern Workplace solution based on Microsoft 365, which kept the user firmly at the center of the transformation.
            View Case Study

          • Testimonials

            We love transforming our customers businesses, take a look at what they have to say about New Signature.

            View Testimonials

          • Featured Testimonial Davis Construction

            With New Signature’s help, Davis was able to take a progressive step forward by migrating their private branch exchange (PBX) phone system to a Voice of Internet Protocol (VoIP) system.
            View Testimonial

        Close
      • Technologies
        • Learn more about the technologies that power New Signature solutions View All Technologies


          • Advanced Threat Analytics
          • Azure Active Directory
          • Azure IoT Suite
          • Azure Site Recovery
          • Cortana Intelligence Suite
          • DocuSign
          • Dynamics 365
          • Employee Self Service
          • Enterprise Mobility Suite
          • Exchange
          • ExpressRoute
          • Hyper-V
          • Microsoft 365
          • Microsoft Azure
          • Microsoft Azure Stack
          • Microsoft Identity Manager
          • Microsoft Intune
          • Microsoft Phone System
          • Microsoft Project
          • Microsoft Teams
          • Nintex
          • Office 365
          • OneDrive for Business
          • Operations Management Suite
          • Power BI
          • SharePoint
          • Skype for Business
          • SQL Server
          • System Center
          • System Center Configuration Manager
          • Visual Studio
          • Windows 10
          • Windows Server
          • Xamarin
          • Yammer

        • New Signature Microsoft Azure

          New Signature has Microsoft-certified Azure experts and consultants who assess your business, develop the virtual machines that you need to meet your goals and streamline your operations through the cloud. Learn More

        • New Signature Microsoft Licensing

          A Microsoft environment is not complete and usable until the proper licensing has been purchased and activated for your organization. Learn More

        Close
      • Explore
          • Guides & Ebooks

            Dive deeper into education with your team by leveraging our expert-developed guides and eBooks.

            View All Guides & Ebooks

          • Infographics

            Rich with statistics and information, our infographics are great tools for quick but insightful learning.

            View All Infographics
          • Podcast: Office Explorers

            Join Kat and Rob monthly as they chat with New Signature experts and explore the world of O365.

            Listen to Podcasts

          • Videos

            Visit our videos stream to access recorded webinars, service information and to learn more about us.

            WATCH ALL VIDEOS
          • Flyers

            Searching for information about our services? Our flyers are a great takeaway for all those details.

            VIEW ALL FLYERS

          • Featured Stream

            Learn more about the tooling and expertise required to unlock productivity and mobilize your teams.

            MODERN WORKPLACE
        Close
        Close
      Blog

      Adding Unit Tests to Legacy Code

      New Signature / Blog / Adding Unit Tests to Legacy Code
      May 13, 2020May 5, 2020| Facundo Gauna
      • Facebook
      • Twitter
      • LinkedIn
      • Print

      You’ve heard it before, probably a million times. “Developers must write unit tests.” Easier said than done. There’s the big monoliths, the ugly codebases, the mission-critical code that one really knows how it works. Well, it turns out that those ugly pieces of software that provide a lot of value are probably going to require new changes.

      I’ve said myself long ago. It’s daunting thinking about making a change to a convoluted codebase and also gut-wrenching at the thought of introducing a breaking-change. The less we change, the less risk of the change, right? Not quite.

      The more the codebase goes without unit tests, the less clean-up that happens, the more the technical debt grows. At some point, things will break and it’s going to take a whole lot of coffee, long hours, and stress to make it work again.

      Why?

      Unit tests are difficult to create at first. But, after some time and with practice, teams can reach an inflection point where they are able to deliver higher quality code with automated tests faster than untested code. For the skeptics, it might be hard to believe yet research studies like the 2017 State of DevOps report show us the end result. High-performing IT organizations are to ship code to production multiple-times faster than other orgs. How often do they deploy? At least once a day per developer per day. Unit tests are an ingredient to their success.

      But wouldn’t deploying this much mean that production breaks all the time? Well, no. They’ve also found that high-performers not only go fast but they build more reliable systems. Software delivery and development doesn’t have to be the way it used to be. We don’t have to trade agility for stability.

      How do I get there?

      Unit-testing a green-field application is much easier. Technical debt is zero and you have flexibility into start building the product with a test-driven approach. You also have more flexibility to choosing design patterns and adopting principles that make it much easier to write tests.
      On the other hand, when adding tests to a legacy app, there’s going to be a lot of refactoring. Usually, the code is not written in a way that adding unit tests is easy. Code is tightly coupled, there’s a lot of external dependencies, and probably a lot of technical debt.

      Here’s some tips to adding tests to legacy code.

      1. Start Somewhere

      When creating a new feature or fixing a bug, take some time to think about how to write some tests about the changes you’re implementing. There’s really good literature on some techniques you could use – I recommend the book “Working Effectively with Legacy Code.”

      Typically, validation behavior or utilities classes could be a great place to start and practicing. Refactor and validate you’re on the right track often. Don’t wait until the end and submit a massive code review to your peers.

      In some situations, you might find that refactoring the code to make it testable is more difficult than you anticipated. It’s ok to stop. Sometimes the level of difficulty exceeds the reward.

      2. Incrementally

      Add tests as part of your daily workflow. Execute your unit-tests as part of your CI/CD pipeline. Make the code coverage results visible and start appreciating the progress that you’re making.

      What you don’t want to do is stop feature development just to start adding unit tests. It’s a lot of pressure to get X amount of code coverage within a certain time period. There’s simply too much risk.
      Instead, find opportunities how to add tests as you go along. Pay attention to the areas that are painful to test – tests and refactoring could be beneficial.

      3. Take on Technical Debt

      Is there a component that is so difficult to test and convoluted that keeps you up at night? Is it so complex that no one really knows how it works and therefore no one wants to “touch” it? Consider taking on some technical debt on purpose – start slowly rewriting the component using Test Driven Development (TDD) and deploy it to production frequently. For example, start rewriting it based on your understanding of what the legacy piece does today. Then, if you’re not fully sure of how it works or you’re not finished, leave it as dead code. Dead code simply means that it will only get executed by unit tests. The power of dead code is that you can still release it to production and there’s no need to keep a long lived branch for the rewrite.

      When the time comes, you can simply change the execution paths to point to the new rewritten & fully tested module. Perhaps, you could also choose to throw a feature flag in front so that this is only available to some users and you can quickly revert back if something goes wrong.

      At New Signature, we’re huge believers in helping companies create more business value through Azure and DevOps. I also believe that to be an effective and high-performing IT organization, teams must unit test. Unit testing helps organizations move faster and deploy more frequently. Unit testing helps dramatically with lower lead times – development teams no longer have to wait business days or weeks to get feedback on whether everything works. In the end, software will become more stable because of the reduced technical debt, increased simplicity, and increased clarity.

      With the pressures of work and dead-lines, unit-testing a legacy app can be very daunting. We can partner with you to create hands-on workshops that empower developers to start unit-testing immediately. We’ll show you how to get the most out automated tests by executing them often and making those results highly visible to the team. Sometimes, these key and fundamental practices like unit-testing can have a bigger impact than a new architecture or new virtualization technologies.

      Categories
      Tips and Tricks
      Contact New Signature

      Events

      Thu 28

      Power Platform Series: Drive Organizational Productivity with Power Virtual Agents

      January 28 @ 10:00 am - 10:45 am EST
      Feb 16

      Cognizant’s Experience Lab for Continuous Testing with Azure

      February 16 @ 12:00 pm - 2:00 pm EST

      View More

      New Signature
      New Signature HQ
      901 K Street NW, Suite 450
      Washington, DC 20001
      Phone: 202-452-5923
      New Signature Canada HQ
      7th Floor, 5140 Yonge Street
      Toronto, ON M2N 7J8
      Phone: 416-971-4267
      New Signature UK HQ
      57 Bermondsey Street
      London SE1 3XJ
      Phone: +44 (0) 845-402-1752

      About

      • Company
      • Awards
      • News
      • Leadership
      • Partners
      • Industries

      Solutions

      • Intelligent Enterprise Solutions
      • Intelligent Workplace Solutions
      • Intelligent Cloud Solutions

      Services

      • GO
      • Intelligent Enterprise
      • Intelligent Workplace
      • Intelligent Cloud

      Client Stories

      • Client Stories
      • Testimonials

      Explore

      • Guides & Ebooks
      • Podcasts
      • Flyers
      • Infographics
      • Videos
      Copyright © 2021 New Signature
      • Blog
      • Events
      • Careers
      • Help
      • Anti Slavery
      • Privacy Policy
      • Contact
      • About
        • Company
        • Awards
        • News
        • Leadership
        • Partners
        • Industries
      • Services
        • GO
        • Intelligent Enterprise
        • Intelligent Workplace
        • Intelligent Cloud
      • Client Stories
        • Case Studies
        • Testimonials
      • Technologies
      • Explore
        • Guides & Ebooks
        • Infographics
        • Podcast: Office Explorers
        • Videos
        • Flyers
      • Blog
      • Events
      • Careers
      • Contact
      • Search
      Cookie Settings
      New Signature uses "Required Cookies" to run our website, "Functional Cookies" used by third parties to personalise marketing, including social media features.

      Change your preferences by clicking the “Cookie Settings” link at the bottom of every page. Learn more about cookies in our Cookie Policy and our Privacy Policy. By clicking the “Accept Cookies” button below, you consent to our use of cookies.

      Please note that “Required Cookies” will be set regardless of your consent.
      Cookie SettingsAccept Cookies
      Privacy & Cookies Policy
      Performance

      Performance Cookies provide Content Delivery Network assets that deliver faster site content delivery capabilities.

      Required

      These cookies are required mainly in order to deliver Multilanguage site capabilities.

      Functional

      Functional Cookies allow us to provided advanced media capabilities including videos, surveys and other multimedia capabilities.

      Disabling Functional cookies will block the playing of videos and other multimedia site components.

      Targeting

      Targeting Cookies are used to capture user information in order for New Signature to deliver better user experiences.

      Save & Accept