Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
2 answers
1k views

Migrating legacy code with singletons to Dependency injection

I'm working on a larger, older project. Our code is littered with classical singletons, i.e. classes like public class ABCService { private static final instance = new ABCService(); public ...
Johannes Hahn's user avatar
-1 votes
1 answer
764 views

How to create input data for unit tests for an API client?

I am building the initial set of unit tests for my team's legacy API client system. We have been writing integration tests, but have no unit tests. It's a Sinatra server that accepts requests from our ...
Eric's user avatar
  • 107
1 vote
3 answers
538 views

Refactor unit tests?

When we work with legacy code and need to do changes, we first write tests on the current behavior. That way we can implement new changes with confidence. We can even refactor the code. Legacy code is ...
JayZ's user avatar
  • 827
-1 votes
2 answers
227 views

Won't a characterization/regression test fail when a bug is fixed?

Let's assume that you are trying to refactor a legacy code to make it easier to understand and more testable, how can you do that? In the book "Working with Legacy Code", a characterization/...
A.Shoman's user avatar
  • 117
0 votes
2 answers
142 views

Should I refactor this class to use a Factory?

Given the following class in a Legacy code base without any UT's. So any refactoring done should be done on the smallest possible scale, just in order to be able to write UT's. public class Person { ...
Complexity's user avatar
8 votes
3 answers
3k views

How do I write unit tests for legacy code (that I don't understand)?

Forward I've read a lot of things before asking this question, including many relevant questions right here on SE: (Software Engineering SE) Writing tests for code whose purpose I don't understand (...
user avatar
-2 votes
1 answer
267 views

Documenting business logics of legacy application having no unit test

I have joined a team in company and this team owns few services, which are used widely by many other user facing internal/external UI apps and other internal apis. My manager gave me rough idea that ...
PKV's user avatar
  • 181
3 votes
4 answers
1k views

Unit testing Systems with Logic Tightly Coupled with Data

I understand there are many questions in this site revolving around the same concept, but I could not get a precise answer for my case. Problem I am handling an ERP System, with code base in both: ...
A.Rashad's user avatar
  • 604
0 votes
3 answers
527 views

Bug Fixing Code With No Tests

I am regularly given code with bugs in it and told to fix the bugs without introducing any more. My approach is usually as follows: Identify the bug's issue, e.g. method is returning an empty list and ...
TheCoder's user avatar
  • 179
0 votes
2 answers
494 views

How to add cases to large legacy code base project? [duplicate]

There is a legacy project full of C++ code. As a MFC GUI project, it contains lots of businesses logic out of control and beyond average level programmer to understand. To work on such GUI project, is ...
upton's user avatar
  • 673
2 votes
4 answers
801 views

How to refactor a myriad of similar classes

I'm faced with similar classes A1, A2, ..., A100. Believe it or not but yeah, there are roughly hundred classes that almost look the same. None of these classes are unit tested (of course ;-) ). Each ...
TobiMcNamobi's user avatar
  • 1,171
74 votes
10 answers
8k views

Does it make sense to write tests for legacy code when there is no time for a complete refactoring?

I usually try to follow the advice of the book Working Effectively with Legacy Code. I break dependencies, move parts of the code to @VisibleForTesting public static methods and to new classes to make ...
is4's user avatar
  • 779
9 votes
4 answers
2k views

I have 200k lines of poorly designed code, will units tests or integration tests be more valuable? [duplicate]

I've inherited a lot of poorly designed code; the code has no tests. I am putting tests in place before I attempt a major refactor, but I have run into a problem with my unit tests. The problem is, I ...
Buttons840's user avatar
  • 1,886