Check out a free preview of the full Software Developer Success: Soft Skills & Testing course

The "Writing Tests Exercise Setup" Lesson is part of the full, Software Developer Success: Soft Skills & Testing course featured in this preview video. Here's what you'd learn in this lesson:

Francesca introduces the Gilded Rose exercise, which involves working with a legacy system and making changes safely with tests. The goal is to add a new feature to the existing code without breaking any existing functionality.

Preview
Close
Get $100 Off
Get $100 Off!

Transcript from the "Writing Tests Exercise Setup" Lesson

[00:00:00]
>> Francesca Sadikin: So we're gonna be moving into our coding exercise now. The goal of this project is that we're going to learn to work in a legacy system and how to make changes safely with test, creating seams, and I'm also gonna cover a few refactoring techniques. Gilded Rose is a shop of magical items, and it has asked us to add a new feature to their project while making sure we don't break existing functionalities.

[00:00:32]
So my little prompt to you is what is the plan of attack here? Knowing that there is an existing source code that's working, there are no tests, and the code itself is not great. So, how would you plan on injecting our new code without breaking existing functionality?
>> Francesca Sadikin: That's a prompt.

[00:01:00]
>> Speaker 1: You can run the tests.
>> Francesca Sadikin: What if there are no tests? I know it seems a little obvious, but right test okay?
>> Speaker 2: You can also communicate and do a manual test as well, like QA, number one, to see if the program still runs the same way.

[00:01:19]
>> Francesca Sadikin: Okay, so, yes so manual testing would be really hard when you start refactoring the code, because there you would have to just manually test so many different conditions. So writing test is the great first step, because then we have this like, immediate signal that whatever we're about to touch is going to still work or it's going to fail.

[00:01:47]
So the actual plan of attack here is we're not going to just inject our new code into the system. We're going to write tests to ensure all of the existing functionality, then we're gonna refactor the code, because I'll show you, the code's really hard to work in. And then that's when we're gonna actually implement our new functionality by writing the test first, and then write the code.

[00:02:14]
And in any moment during this, if there is a refactoring opportunity, we're We're going to take it. So an introduction to this system you don't have to read this too carefully because we're about to go over it again in via code but, essentially they have a set of base items that there are, conditions for.

[00:02:33]
And there is also specialty items that we need to cover.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now