... but once you have discovered, you can verify that the class acts the same way over and over again. If you keep your print statements, you're discovering...
4792
Vladimir Bossicard
vbossica
May 1, 2002 5:39 pm
... I bet that if you have a method that stores something into a database, you have another one that reads from the database... So simply use both methods in a...
4793
Vladimir Bossicard
vbossica
May 1, 2002 5:46 pm
... answers: a) does it bother you? b) acts like specified the rational is that every test must be independant from the others. If you create one object per...
4794
J. B. Rainsberger
nails762
May 1, 2002 5:48 pm
... What's more, you may not need your print statements to discover. Here is a common trick I use. Suppose I want to debug something by checking a value. I...
4795
Shane Celis
shane@...
May 1, 2002 7:08 pm
These are great tips. You may have just given me the necessary tools to break a very old habit of mine. -shane...
4796
Morris, Chris
workmo
May 1, 2002 8:48 pm
... What's wrong with forcing production code to change only to make it more testable? I came into the JUnit-ish lifestyle with this belief, but I don't hold...
4797
David V. Olivier
slimbola
May 1, 2002 9:25 pm
The rule of thumb is that unit tests should be as standalone as possible, and dependencies on external resources such as databases or files should be minimized...
4798
Vladimir Bossicard
vbossica
May 1, 2002 9:25 pm
... You don't have to change the return value of the method to be able to test it. But if you want to, go ahead. I think that a testing tool can suggest you...
4799
Erik Hanson
hanson_erik
May 1, 2002 10:20 pm
... What I do in this case is embed the contents of the file in the test as a string constant and use that for testing. However, sometimes I think you do have...
4800
Timothy Wall
twall@...
May 1, 2002 10:22 pm
Some would suggest creating "Mock" objects defined within your test that pretend to be those external resources. Sometimes this is a viable option, but at...
4801
Alain Ravet
alain_ravet
May 1, 2002 10:41 pm
... You can replace File by Writer : Replace public XMLObject parse (File source) .. by public XMLObject parse (Writer source) .. and test it with : ... ...
4802
Mike Clark
clarkware
May 1, 2002 11:26 pm
... I'll first try to embed the XML text in the test and use a Writer to test the parsing. This usually works for most cases. When I must use external...
4803
J. B. Rainsberger
nails762
May 2, 2002 1:11 am
Tests are merely clients of code, just like any other part of your system. In fact, your unit tests cover all supported uses of your code (over time). If your...
4804
J. B. Rainsberger
nails762
May 2, 2002 1:16 am
Notice, everyone, how the test tool suggested a change that makes this class more generally useful. Hmmmm. I suggest keeping parse(File) and implementing it...
4805
Mike Clark
clarkware
May 2, 2002 1:28 am
... Of course, so did Mike. ;-) Mike -- Mike Clark Clarkware Consulting, Inc. http://www.clarkware.com 720.851.2014...
4806
Mike Clark
clarkware
May 2, 2002 1:30 am
... That qualifies it as a design tool in my book. And an analysis tool, for that matter. Proactive testing is just a beneficial side effect. Mike -- Mike...
4807
Vladimir Bossicard
vbossica
May 2, 2002 1:53 am
... Well, not exactly: One solution ("a directory full of a bunch of xml catalog file variations becomes more readable and understandable than a bunch of...
4808
raju99
May 2, 2002 2:32 am
Hi, I am trying to answer the following question for myself - "What is the best approach for testing get/set methods ?" I have my approach outlined below and...
4809
Anil and Rita Philip
juwo77
May 2, 2002 2:32 am
I shall try to explain more clearly: if(some condition is true) { do some work; return result1; } else { do some other work; return result2; } Here are two...
4810
Anil and Rita Philip
juwo77
May 2, 2002 2:35 am
Vladimir, What I am trying to communicate is different from what you have written. 1) with the db there will be other issues like other processes touching the...
4811
Robert Wenner
robert@...
May 2, 2002 7:44 am
... Why don't you just combine these tests without the inner class? car.setColor (blue); assert_equal (car.getColor, blue); I would not like modifying...
4812
Robert Wenner
robert@...
May 2, 2002 7:47 am
... By writing a test case for each path? Robert...
4813
tumb@...
May 2, 2002 10:32 am
Your ValueCollector class is added to the needed class in order to make public some private or method field in the needed class, isn't it? Is it really OK to...
4814
Andrew Forward
andrewforwar...
May 2, 2002 11:49 am
If I were to test get / set methods, I would 1. make the state variable "protected" (as oppose to private) 2. have my test classes in the same package...
4815
Eric Heikkila
ericheikkila
May 2, 2002 12:13 pm
One thing you could do is create the file on the fly, and feed it to your class. I don't know what language you're using, but in Java I'd probably have the...
4816
Eric Heikkila
ericheikkila
May 2, 2002 12:16 pm
Once again, what I've done in the past is create the directories and files in setUp() and removed them in tearDown(). Depends on how complex the files and ...
4817
Eric Heikkila
ericheikkila
May 2, 2002 12:21 pm
I would tend to agree. Unless the getters and setters are private or protected or something, why bother with the inner class? When I'm writing a test for ...
4818
Morris, Chris
workmo
May 2, 2002 1:19 pm
... JUnit (AFAIK) does not report code coverage, if that's what you're asking. It won't tell you what lines were not executed after a test suite run is done....
4819
Morris, Chris
workmo
May 2, 2002 1:22 pm
... I agree. I don't think a specific tool should form decisions like this. But I do think that I as a programmer should be willing to make changes in ...
4820
Ives Aerts
ivesaerts
May 2, 2002 3:00 pm
... Been there, done that. I needed it to test file system related functions on an embedded platform. Made a TestSetup subclass called DirTreeTest that takes a...