473,626 Members | 3,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unit testing

Does anyone else feel that unittesting is too much work? Not in general,
just the official unittest module for small to medium sized projects?

It seems easier to write some quick methods that are used when needed
rather than building a program with integrated unittesting. I see the
value of it (the official unittest that is)... especially when there's a
lot of source code. But this...

if len(x) != y:
sys.exit('...')

is a hell of a lot easier and quicker that subclassing unittest.TestCa se
on small projects :)

Do others do their own "informal" unit testing?

Just curious,

Brad
Oct 4 '07 #1
27 2539
On 10/4/07, brad <by*******@gmai l.comwrote:
Does anyone else feel that unittesting is too much work? Not in general,
just the official unittest module for small to medium sized projects?

It seems easier to write some quick methods that are used when needed
rather than building a program with integrated unittesting. I see the
value of it (the official unittest that is)... especially when there's a
lot of source code. But this...

if len(x) != y:
sys.exit('...')

is a hell of a lot easier and quicker that subclassing unittest.TestCa se
on small projects :)

Do others do their own "informal" unit testing?

Doctest is commonly given as the alternative to people who feel this
way. Personally, I find that anything worth testing is worth having a
test directory and independent unit tests for.
Oct 4 '07 #2
On Oct 4, 1:02 pm, brad <byte8b...@gmai l.comwrote:
Does anyone else feel that unittesting is too much work? Not in general,
just the official unittest module for small to medium sized projects?

It seems easier to write some quick methods that are used when needed
rather than building a program with integrated unittesting. I see the
value of it (the official unittest that is)... especially when there's a
lot of source code. But this...

if len(x) != y:
sys.exit('...')

is a hell of a lot easier and quicker that subclassing unittest.TestCa se
on small projects :)

Do others do their own "informal" unit testing?

Just curious,

Brad
I actually do a lot of unit testing. I find it both annoying and
highly necessary and useful. I can't tell you how many bugs have been
squashed before ever leaving my cube by good unit testing. I also
agree that it can be a real pain. My opinion is you should do TDD
(test-driven development) and do it as much as you can tolerate. It
really will save you time and hassle in the long run.

Oct 4 '07 #3
brad <by*******@gmai l.comwrites:
Does anyone else feel that unittesting is too much work? Not in
general, just the official unittest module for small to medium sized
projects?
Yeah, unittest is sort of a Java-ism. You might try the newer doctest
module instead.
Oct 4 '07 #4
da********@yaho o.com wrote:
On Oct 4, 1:02 pm, brad <byte8b...@gmai l.comwrote:
>Does anyone else feel that unittesting is too much work? Not in general,
just the official unittest module for small to medium sized projects?
[snip]
I actually do a lot of unit testing. I find it both annoying and
highly necessary and useful.
+1 QOTW.

I feel exactly the same way. Writing tests (whether you use unittest,
doctest, py.test or whatever) is always a pain and a time sink. But
writing those tests catches so many bugs that it's worth it for any code
you expect to use more than twice. =)

STeVe
Oct 4 '07 #5
Paul Rubin a écrit :
brad <by*******@gmai l.comwrites:
>>Does anyone else feel that unittesting is too much work? Not in
general, just the official unittest module for small to medium sized
projects?


Yeah, unittest is sort of a Java-ism. You might try the newer doctest
module instead.
Or py.test or nose, which are both more complete than doctest and more
pythonics than the unittest module.
Oct 4 '07 #6
Chris Mellon wrote:
Doctest is commonly given as the alternative to people who feel this
way. Personally, I find that anything worth testing is worth having a
test directory and independent unit tests for.
I like keeping my tests separate as well, and doctest does allow this, using
doctest.testfil e(). That is, despite the name, doctests do not necessarily
need to appear in docstrings :-)

Jeffrey
Oct 4 '07 #7
On Behalf Of Bruno Desthuilliers
Or py.test or nose, which are both more complete than doctest
and more pythonics than the unittest module.
I second the recommendation of nose. It makes it fantastically easy to write
and run unit tests.

Also, in my experience unit tests help reduce bugs in the development
process, but their main benefits are making code more modular (writing for
testing tends to reduce dependencies) and easier to modify (less fear in
refactoring).

Regards,
Ryan Ginstrom

Oct 5 '07 #8

On Oct 4, 2007, at 3:02 PM, brad wrote:
Does anyone else feel that unittesting is too much work? Not in
general,
just the official unittest module for small to medium sized projects?

It seems easier to write some quick methods that are used when needed
rather than building a program with integrated unittesting. I see the
value of it (the official unittest that is)... especially when
there's a
lot of source code. But this...

if len(x) != y:
sys.exit('...')

is a hell of a lot easier and quicker that subclassing
unittest.TestCa se
on small projects :)

Do others do their own "informal" unit testing?

Just curious,

Brad
--
http://mail.python.org/mailman/listinfo/python-list
Brad:

If the program is more than 100 lines or is a critical system, I
write a unit test. I hate asking myself, "Did I break something?"
every time I decide to refactor a small section of code. For
instance, I wrote an alarm system in Python for a water treatment
plant. If the chlorine, pH, or turbidity are out of spec, an email
message is sent to the plant operator's pager. Because of the nature
of the alarm system, extensive field testing was out of the question.
Unit testing was the only way to ensure it worked without disrupting
the plant operation.

Craig

Oct 5 '07 #9
On 4 Okt., 22:49, Jeffrey Froman <jeff...@fro.ma nwrote:
Chris Mellon wrote:
Doctest is commonly given as the alternative to people who feel this
way. Personally, I find that anything worth testing is worth having a
test directory and independent unit tests for.

I like keeping my tests separate as well, and doctest does allow this, using
doctest.testfil e(). That is, despite the name, doctests do not necessarily
need to appear in docstrings :-)

Jeffrey
And they are definitely no unit tests. Instread they are diffs on
lexical content of an executed session protocol of arbitrary size
( which might be customized using a mini language ). So they are
sensitive to all kinds of ambient changes being irrelevant for the
*functional unit* to be tested.

I wish all people good luck porting their doctests to Python 3.0.

Oct 5 '07 #10

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

Similar topics

4
3732
by: Hugh Cowan | last post by:
Hello, I don't program full-time (anymore), but I do try and stay on-top of the latest technologies and like most are always trying to upgrade my skills and remain current (as much as is possible). Most of my programming these days involves using PHP for creating script files for automating tasks and procedures (locally), and also for anything that might be needed by our divisional Intranet (not a huge site by any stretch of the...
11
2320
by: rhat | last post by:
Hi Everyone, I've recently been reading some articles about unit-testing in Python , but I am a bit confused: where do I go to get started with this? I tried googling for "unittest" but all I've found are some old links to projects that already use it, and the older (as the articles put it) PyUnit project. I'm sorry if this is a obvious question or one that has already been answered, but unit-testing sounds interesting and I'm not sure...
14
2737
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
4
2159
by: Peter Rilling | last post by:
Does VS.NET 2005 Professional support integrated unit testing, or is that only with the team system?
72
5226
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: http://geosoft.no/development/unittesting.html Thanks.
4
18963
by: Dat AU DUONG | last post by:
Hi, I am new to Unit testing, could you tell me where I could find information (hopefully step by step) and what is the benefit of unit testing. I am a sole developer in a company, therefore I don't get expose to much of this technology. Thanks in advance. Regards Dat.
5
6515
by: shuisheng | last post by:
Dear All, I was told that unit test is a powerful tool for progamming. If I am writing a GUI code, is it possible to still using unit test? I have a little experience in using unittest++. But I can not work out a way to use it to test GUI code. Thanks a lot!
176
8327
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write their own unit test framework, and then in a lab session see if I can get them to write their own. To give them an example I've created the following UTF class (with a simple test program following). I would welcome and suggestions on how anybody...
48
2483
by: Ark Khasin | last post by:
Unit testing is an integral component of both "formal" and "agile" models of development. Alas, it involves a significant amount of tedious labor. There are test automation tools out there but from what limited exposure I've had, they are pricey, reasonably buggy, and require compiler/target adaptation. Out of my frustration with two out of two of them came my own. Its instrumentation approach is based solely on profound abuse of the C
5
2240
by: Ben Finney | last post by:
Howdy all, PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an enhancement for entry points to Python programs: a module attribute (named '__main__') that will be automatically called if the module is run as a program. The PEP has status "Rejected", citing backward-compatibility issues, and Guido's pronouncement that "It's not worth the change (in docs, user habits, etc.) and there's nothing particularly broken."
0
8266
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8199
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.