473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Refactoring test units after an extract method

This is not strictly python related, but it's not strictly TDD related
either. Anyway, here it goes.

There's something that I was never quite sure how to handle with test
units: How to handle the test unit refactoring after a method
extraction.

Let's say that you have a function foo() that does A and B. You have
tests for foo() that check that A and B are executed properly. Then,
you add another function, bar(), that needs to do B, so you add a
third function, baz() that does B and make foo() and bar() call baz().

How to you handle the tests? Copy over the tests you had for foo() and
apply them to bar()? I don't like copy and pasting code. Move the B
related tests to baz()'s tests? Then your tests wouldn't fail if you
stopped calling baz() in foo() and bar().

What I do right now is that I mock baz() and verify that it is called
in foo() and bar(), with the right arguments. Then I move the B
related tests to baz(). It kind of works, but somehow, it doesn't feel
like the ideal solution to me. But then again, it's kind of the same
thing as if baz() was a third party function: You have to mock it to
test foo() and bar() properly without testing the third party code.

What do you people think?

Jun 5 '07 #1
0 827

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thierry Miceli | last post by:
Hello, Ref++ is a new C++ refactoring utility. A beta release is now available. It integrates with Visual Studio 2003 and handles the following refactorings for standard C++: - ...
2
by: Sachin Garg | last post by:
Hi, I was trying to find (like many others here) a tool for refactoring C++ code as I have lately been noticing that I spend most of my coding time doing refactoring and some refactoring which...
6
by: Dean Ware | last post by:
Hi, I am part way through developing a C++ application. I am developing it on my own and using VC++ 6.0. I am now at the stage where I wish to start tidying up my code. I have lots of...
8
by: Frank Rizzo | last post by:
I keep hearing this term thrown around. What does it mean in the context of code? Can someone provide a definition and example using concrete code? Thanks.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.