Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

junit · JUnit, the Java unit testing framework written by Kent Beck and Erich Gamma.

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 31224
  • Category: Java
  • Founded: Nov 6, 2000
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Messages

Advanced
Messages Help
Messages 3423 - 3452 of 24385   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#3423 From: ks558@...
Date: Mon Dec 3, 2001 5:17 pm
Subject: Does the tear down of fixtures get fired if my test spawns a thread?
pescador29
Send Email Send Email
 
I have a test fixture that appears to be calling the tear down method
as soon as my test method creates and spawns a thread.  This causes
my test to fail.  Is this the desired effects of the test fixtures
setup and tear down?  I thought setup was called before the method
and tear down was called upon finishing the method?

Here is what I do:
package suncertify.test;

/**
  * TestDatabase
  */
import junit.framework.*;
import suncertify.db.*;
import java.util.*;

public class TestDatabase extends TestCase
{
   public static Data d1 = null;
   private static boolean isClient1Finished = false;
   protected void setUp(){
     isClient1Finished = false;
     try {
       System.err.println("Initialized dbase");
       d1 =  new Data("./build/db.db");
     } catch (Exception exc){
       exc.printStackTrace();
     }
   }
   protected void tearDown(){
     d1 = null;
     System.err.println("undid dbase...");
   }

   public void testConcurrentUsers(){
     try {
       isClient1Finished = false;
      if(d1==null) TestCase.fail("Database is null in the beginning,
but don't know why");

       // client2 gets lock.
       new Thread(new Runnable(){
         public void run(){
           try {
             System.err.println("In second client...");
             if(d1==null) TestCase.fail("Database is null, but don't
know why");
             d1.lock(1);
             Thread.sleep(1000);
             d1.unlock(1);
             isClient1Finished = true;
           } catch (Exception exc){
             exc.printStackTrace();
             TestCase.fail("Second Client failed due to unexpected
exception.");
           }
         }
       }).start();
       // client1 gets lock
       d1.lock(1);
       TestCase.assertTrue(isClient1Finished);
     } catch (Exception e){
       e.printStackTrace();
       TestCase.fail("Test Concurrent Users failed for unknown
reason.");
     }
   }
}

I get the following output:
Initialized dbase
undid dbase...
In second client...
junit.framework.AssertionFailedError: Database is null, but don't
know why
     at junit.framework.Assert.fail(Assert.java:51)
     at suncertify.test.TestDatabase$1.run(TestDatabase.java:82)
     at java.lang.Thread.run(Thread.java:484)

Any help would be appreciated...

-brent fisher

#3424 From: Robert Sartin <sartin@...>
Date: Mon Dec 3, 2001 6:18 pm
Subject: RE: JUnit Tests and Business Rules
robert_sartin
Send Email Send Email
 
--- Scott Stirling <sstirling@...> wrote:
> J.B., where can one find out more about javax.rules?  Is there a JSR
> you know of?  Sounds interesting.

JSR 94

http://www.jcp.org/jsr/detail/94.jsp

Regards,

Rob


__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com

#3425 From: <evought@...>
Date: Mon Dec 3, 2001 6:42 pm
Subject: Re: Does the tear down of fixtures get fired if my test spawns a thread?
eric_vought
Send Email Send Email
 
I would imagine you have a race condition. teardown() is running because
your testcase has finished (even though your thread is still running.).
What is probly happening is that the call to dl.lock() in your test method
happens before the call in your subthread. This, of course, succeeds
immediately and returns. When/if your thread gets to the dl.lock() call,
it blocks because the lock is already held. Your testcase method returns
and teardown is run().

Look in the archives for earlier posts by me regarding testing threaded
code for some ways you can protect yourself from this kind of thing. You
have to be very certain that everything is going to run in the right
sequence.

On Mon, 3 Dec 2001 ks558@... wrote:

> I have a test fixture that appears to be calling the tear down method
> as soon as my test method creates and spawns a thread.  This causes
> my test to fail.  Is this the desired effects of the test fixtures
> setup and tear down?  I thought setup was called before the method
> and tear down was called upon finishing the method?
>
> Here is what I do:
> package suncertify.test;
>
> /**
>  * TestDatabase
>  */
> import junit.framework.*;
> import suncertify.db.*;
> import java.util.*;
>
> public class TestDatabase extends TestCase
> {
>   public static Data d1 = null;
>   private static boolean isClient1Finished = false;
>   protected void setUp(){
>     isClient1Finished = false;
>     try {
>       System.err.println("Initialized dbase");
>       d1 =  new Data("./build/db.db");
>     } catch (Exception exc){
>       exc.printStackTrace();
>     }
>   }
>   protected void tearDown(){
>     d1 = null;
>     System.err.println("undid dbase...");
>   }
>
>   public void testConcurrentUsers(){
>     try {
>       isClient1Finished = false;
>      if(d1==null) TestCase.fail("Database is null in the beginning,
> but don't know why");
>
>       // client2 gets lock.
>       new Thread(new Runnable(){
>         public void run(){
>           try {
>             System.err.println("In second client...");
>             if(d1==null) TestCase.fail("Database is null, but don't
> know why");
>             d1.lock(1);
>             Thread.sleep(1000);
>             d1.unlock(1);
>             isClient1Finished = true;
>           } catch (Exception exc){
>             exc.printStackTrace();
>             TestCase.fail("Second Client failed due to unexpected
> exception.");
>           }
>         }
>       }).start();
>       // client1 gets lock
>       d1.lock(1);
>       TestCase.assertTrue(isClient1Finished);
>     } catch (Exception e){
>       e.printStackTrace();
>       TestCase.fail("Test Concurrent Users failed for unknown
> reason.");
>     }
>   }
> }
>
> I get the following output:
> Initialized dbase
> undid dbase...
> In second client...
> junit.framework.AssertionFailedError: Database is null, but don't
> know why
>     at junit.framework.Assert.fail(Assert.java:51)
>     at suncertify.test.TestDatabase$1.run(TestDatabase.java:82)
>     at java.lang.Thread.run(Thread.java:484)
>
> Any help would be appreciated...
>
> -brent fisher
>
>
>
> To unsubscribe from this group, send an email to:
> junit-unsubscribe@yahoogroups.com
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>

--
Eric Vought
Chief Technical Officer - QLUE Consulting, Inc.

evought@... toll-free: 888-771-3538  RTP area: 919-816-9901

#3426 From: qingfenglin@...
Date: Mon Dec 3, 2001 6:51 pm
Subject: JUnit bug for XML testing?
qingfenglin
Send Email Send Email
 
I was trying to use Junit to test a simple XML program as following:


=================================================================
public void testNewInstance() throws Exception{
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance
();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        doc.createElement("test");
    }
==============================================================

If I used the Text interface to run the use case, the test is OK, but
if I use GUI interface, I got the exception as following:
java.lang.LinkageError: Class org/w3c/dom/Document violates Loader
constraint
..
..
..
at junit.runner.TestCaseLoader.loadClass(TestCaseClassLoader.java 104)
..

Is that consider as a bug of JUnit?

#3427 From: Shane Duan <sduan@...>
Date: Mon Dec 3, 2001 7:21 pm
Subject: Re: Re: Problems
wolfdancer_dodo
Send Email Send Email
 
Marc,

I checked the files in my junit directory and I don't find any test case
in the junit.jar.  Instead, all the test cases are under the 'junit'
directory.  I tried the following command and it works for me:

C:\Tools\junit3.7>%JAVA_HOME%\bin\java -classpath .;junit.jar
junit.swingui.TestRunner junit.tests.AllTests

Note:
1. Please run it at your junit directory
2. %JAVA_HOME% should be the home path of your JDK.

Shane

Marc Woolfson wrote:

>I _have_ tried this without the -jar option, but get a main method not
>found error.
>
>I think I need to look at the classpaths again, as I have just got it
>working OK on a unix machine after eventually sorting out the setenv
>property.
>
>I have also read the documenation on the installtion of JUnit, and
>really didn't find them to be very useful. In fact, I was quite
>disappointed at the lack of detail it contained.
>
>Hmmm... 'Extension of JUnit using Adapter and Observer design
>patterns' coursework due at end of next week  :(
>
>Marc
>
>

#3428 From: "Holliday, Donald B. (LNG-SHEP)" <dhollida@...>
Date: Mon Dec 3, 2001 7:15 pm
Subject: Unsubscribing
dbholliday
Send Email Send Email
 
<snip>To unsubscribe from this group, send an email to:
junit-unsubscribe@yahoogroups.com</snip>

I have tried many times to unsubscribe from this list, all without success.
This is probably because my company has changed my e-mail address several
times since I subscribed.  I receive e-mail sent to the old address, but
outgoing messages have the new address.

Who can I contact to get dropped from the list.  (The information is great,
but I would rather peruse the archives than receive the daily postings.)

Thanks,

Don Holliday

#3429 From: Scott Stirling <sstirling@...>
Date: Mon Dec 3, 2001 7:28 pm
Subject: RE: JUnit bug for XML testing?
jrun4
Send Email Send Email
 
Holy FAQ, Batman!  Think we should fix this bug?

If the JUnit maintainers added org.xml.sax.* and org.w3c.dom.* to the
default excluded.properties this question would be asked a lot less, and
users wouldn't have to point out the FAQ/archives.

Seriously, that's the problem.

Vladimir?  Others?  Has anyone thought of ways to fix this via refactoring?

I have one idea:

1. Make JUnit use a different repository source for its TestCaseClasLoader,
much like the way that most app servers allow dynamic reloading of JSPs and
Servlets into a custom classloader by _not_ having the custom classloader
use the system classpath.

Scott Stirling
JRun QA
Macromedia


> -----Original Message-----
> From: qingfenglin@... [mailto:qingfenglin@...]
>
> I was trying to use Junit to test a simple XML program as following:
>
>
> =================================================================
> public void testNewInstance() throws Exception{
>        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance
> ();
>        DocumentBuilder db = dbf.newDocumentBuilder();
>        Document doc = db.newDocument();
>        doc.createElement("test");
>    }
> ==============================================================
>
> If I used the Text interface to run the use case, the test is OK, but
> if I use GUI interface, I got the exception as following:
> java.lang.LinkageError: Class org/w3c/dom/Document violates Loader
> constraint
> ..
> ..
> ..
> at junit.runner.TestCaseLoader.loadClass(TestCaseClassLoader.java 104)
> ..
>
> Is that consider as a bug of JUnit?

#3430 From: Vladimir Bossicard <vladimir@...>
Date: Mon Dec 3, 2001 7:35 pm
Subject: Re: JUnit bug for XML testing?
vbossica
Send Email Send Email
 
> Is that consider as a bug of JUnit?


Please search the archive (keyword 'classloader')!  This is a well known
bug from JUnit.

-Vladimir

--
Vladimir Bossicard
www.bossicard.com

#3431 From: Vladimir Bossicard <vladimir@...>
Date: Mon Dec 3, 2001 7:51 pm
Subject: Re: JUnit bug for XML testing?
vbossica
Send Email Send Email
 
> If the JUnit maintainers added org.xml.sax.* and org.w3c.dom.* to the
> default excluded.properties this question would be asked a lot less, and
> users wouldn't have to point out the FAQ/archives.


This is done in the CVS repository but not in an official release.  And
I cannot give you a date for the next release, sorry.

-Vladimir

--
Vladimir Bossicard
www.bossicard.com

#3432 From: "David V. Olivier" <dolivier@...>
Date: Mon Dec 3, 2001 7:54 pm
Subject: User interface issue
slimbola
Send Email Send Email
 
All in all, JUnit has a wonderfully simple and effective user
interface.  There is , however, one behavior that I find troublesome.  This
is the absence of a detailed stack trace when one runs only a single test
case (the second "Run" button).  Instead one only receives pass/fail
information in the status bar (I'm using the Swing UI).

I often find myself in the case where one test of several has failed.  I
make the fix, and then want to test it again.  If I want detailed reporting
I have to run the entire suite.  Some of my tests require time-consuming
set-up operations, and when this is the case the overhead excessive.  Of
course, at some point one needs run the complete suite, but when iterating
between coding and testing it would be nice to have the full functionality
available for running a single test case.

Anyone else have an opinion?

p.s. Forgive me if this issue has come up before, but I couldn't find it
the archives.  Also, one might argue that this is more of a development
issue, but since it relates to the user interface, I'll go ahead and post
it here.



David Olivier
Naval Research Laboratory
Digital Mapping, Charting & Geodesy Analysis Program
Code 7440.2

#3433 From: Vic Williams <process-facilitator@...>
Date: Mon Dec 3, 2001 9:20 pm
Subject: Re: Unsubscribing
process-facilitator@...
Send Email Send Email
 
Holliday, Donald B. (LNG-SHEP) wrote:

> I receive e-mail sent to the old address, but
> outgoing messages have the new address.
>

Yeah, I've had to change my email address three times recently,
so I know how.

> Who can I contact to get dropped from the list.  (The information is great,
> but I would rather peruse the archives than receive the daily postings.)
>

Go to  http://groups.yahoo.com/group/junit


Select members, then go in and edit your stuff. If you don't
know your password, simply ask them to email it to your. They're
interface is helpful.

bye,
vic
--
Vic Williams  - process facilitator - (604)433-5189
--
Check out the book "The Art of Focused Conversation",
and the more recent "for Schools" version.

#3434 From: Thomas SMETS <tsmets@...>
Date: Mon Dec 3, 2001 10:45 am
Subject: Re: User interface issue
smetsthomas
Send Email Send Email
 
Yeap Junit is definitively missing a few feature, like the one you
mentionned. There's also an interresting feature that JUnit needs is a
mean to count the assert(), assertNotNull(), assertNull()...
so some test are heavier than others.

What I've also noticed but in this case it's - I believe - included but
I haven't managed to have it working on my tests, is the following :
When making repetive tests with the same method/TestCase but with
different parameters, it's the need to name the tests to be able to
recognize them.
An example ?
Say for instance that I want to test the behavior of a system on the set
of Real number where the function should have the following behavior :
f(x) gives true :
	 x = -infinite , -5[ & [-4, 3] & 5

f(x) gives false :
	 x = [-5, -4[ & ]3, 5[ & ] 5, + infinite

f(x) should throw an exception when x = 5

Now I can definitevely write three TestCases.
1°. testF_X_OK();
2°. testF_X_NOK();
3°. testF_X_throws_Exception();

but modify the internal state of my TestCase to reach the requested
validation*s*It would be nice to put some comments on the TestCase.
I belive the TestCase.setName(String aTestCaseName) method is there for
that but I never managed to have it working.

Of course ideally, the TestCase.setComment() ethod should come from
javadocs... ;-)


Thomas,




David V. Olivier wrote:

> All in all, JUnit has a wonderfully simple and effective user
> interface.  There is , however, one behavior that I find troublesome.  This
> is the absence of a detailed stack trace when one runs only a single test
> case (the second "Run" button).  Instead one only receives pass/fail
> information in the status bar (I'm using the Swing UI).
>
> I often find myself in the case where one test of several has failed.  I
> make the fix, and then want to test it again.  If I want detailed reporting
> I have to run the entire suite.  Some of my tests require time-consuming
> set-up operations, and when this is the case the overhead excessive.  Of
> course, at some point one needs run the complete suite, but when iterating
> between coding and testing it would be nice to have the full functionality
> available for running a single test case.
>
> Anyone else have an opinion?
>
> p.s. Forgive me if this issue has come up before, but I couldn't find it
> the archives.  Also, one might argue that this is more of a development
> issue, but since it relates to the user interface, I'll go ahead and post
> it here.
>
>
>
> David Olivier
> Naval Research Laboratory
> Digital Mapping, Charting & Geodesy Analysis Program
> Code 7440.2
>
>
> To unsubscribe from this group, send an email to:
> junit-unsubscribe@yahoogroups.com
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/>.


--


rue J. Wytsman 62
B - 1050 Brussels
Belgium
Tel. : +32 (0)2 742 05 94 (GMT+1)
yahoo-id : smetsthomas

#3435 From: Vladimir Bossicard <vladimir@...>
Date: Mon Dec 3, 2001 11:14 pm
Subject: Re: User interface issue
vbossica
Send Email Send Email
 
> Now I can definitevely write three TestCases.
> 1°. testF_X_OK();
> 2°. testF_X_NOK();
> 3°. testF_X_throws_Exception();
>
> but modify the internal state of my TestCase to reach the requested
> validation*s*It would be nice to put some comments on the TestCase.
> I belive the TestCase.setName(String aTestCaseName) method is there for
> that but I never managed to have it working.


Not exactly.  Shortly, in you example:
- the TestSuite initialized with your class will contain 3 TestCase
objects, each one initialized with a different name ("testF_X_OK",
"testF_X_NOK" and "testF_X_throws_Exception")
- the name of the TestCase is used by the runner to know the method that
must be called
- to summarize: read "methodName" instead of "name"

-Vladimir


--
Vladimir Bossicard
www.bossicard.com

#3436 From: Thomas SMETS <tsmets@...>
Date: Mon Dec 3, 2001 12:00 pm
Subject: Re: User interface issue
smetsthomas
Send Email Send Email
 
Sorry Vladimir I expressed myself incorrectly :
What I meant is that my TestCase would need three methods, as mentionned
but the TestSuite would need approx. twice as many Tests as there are
boundaries.
Typically, testF_X_OK() or testF_X_NOK()
with x = x0,
with x = x0 + epsilon
& with x = x0 - epsilon

Regards,

Thomas,



<snip>
  > Now I can definitevely write three TestCases.
  > 1°. testF_X_OK();
  > 2°. testF_X_NOK();
  > 3°. testF_X_throws_Exception();
  >
  > but modify the internal state of my TestCase to reach the requested
  > validation*s*It would be nice to put some comments on the TestCase.
  > I belive the TestCase.setName(String aTestCaseName) method is there for
  > that but I never managed to have it working.


Not exactly.  Shortly, in you example:
- the TestSuite initialized with your class will contain 3 TestCase
objects, each one initialized with a different name ("testF_X_OK",
"testF_X_NOK" and "testF_X_throws_Exception")
- the name of the TestCase is used by the runner to know the method that
must be called
- to summarize: read "methodName" instead of "name"

-Vladimir

</snip>



--


rue J. Wytsman 62
B - 1050 Brussels
Belgium
Tel. : +32 (0)2 742 05 94 (GMT+1)
yahoo-id : smetsthomas

#3437 From: Vladimir Bossicard <vladimir@...>
Date: Tue Dec 4, 2001 12:55 am
Subject: Re: User interface issue
vbossica
Send Email Send Email
 
> What I meant is that my TestCase would need three methods, as mentionned
> but the TestSuite would need approx. twice as many Tests as there are
> boundaries.
> Typically, testF_X_OK() or testF_X_NOK()
> with x = x0,
> with x = x0 + epsilon
> & with x = x0 - epsilon


You would like to have a TestSuite that generates tests for all possible
values (and you pass this value to the test via a Property object, for
example).  It's fine but may I ask: do you really need to test your
class with every possibilities?  I don't think so.  You cannot test
everything (imagine if you want to test a drawing program with endless
possibilities).

What I would do (IMHO):

- test the methods OK, NOK and ThrownError with the boundaries and 2/3
values (so you know that your class is doing what it should do)
- if I really want to test all values of my class, a better way is to
stress test it with (not 100% correct for your specifications, but just
to give you an idea):

for (int i=-infinite; i<-5; i++) {
     try {
        if (myClass.f(i) == false)
           fail();
     } catch (ExpectedException e) {
        // fine or not fine, depends on i
     } catch (Exception e) {
        // not a normal exception
        fail();
     }
}
...

(so you know that your method is not doing what it should not do)

Because it's really time consuming you should only do it:
-overnight (unless you like to spend time in the cafeteria during the day)
- only choose a panel of values to test.

I haven't seen any stress testing extensions, maybe something to implement.


-Vladimir


--
Vladimir Bossicard
www.bossicard.com

#3438 From: Thomas SMETS <tsmets@...>
Date: Mon Dec 3, 2001 12:57 pm
Subject: Re: Using Log 4 J statementin JUnit
smetsthomas
Send Email Send Email
 
Vladimir Bossicard wrote:

>> Bcoze AFAIK you can write your own extensions, like JUnitPerf
>> HTTPUnit, ... did.
>
>
>
> Writing an extensions add a functionality but does not influence _how_
> the tests are run.
>
> example: when a class doesn't have any test, an error is raised -> you
> tests fail -> pretty annoying if you're doing a nightly build
> my solution: a simple warning is sent and the runner handle it.  If you
> have specified that warning are deadly, your build will fail otherwise
> it will only be a message on the log.
>

short answer : I think you should use ant for that instead...

Longer :
Though I C yr point, I believe you should try to work out yr solution
outside the Unit testing FrameWork !
Tools need to collaborate but do not need especially to be integrate.


>
>>> - support of XML
>>
>>
>> Where ?
>> To do what ?
>
>
>
> 2 idea:
> - replace the AllTests.java by an XML file. Advantage: no need to
> recompile if you only want to run a single test case.  You'll be able to
>  run a named testsuite or a single testcase

OK,
I see yr point.
One could code that as an extension instead, too ...
Or as a Code generating class based on XML too.
I personnally believe the AllTests.java is also a (big) mistake.
I'm unfortunatelly too lazy to change it :-D
Why don't you deliver a class that does it, simply ?


> - standard output in xml.  Only need some filters to transform the
> result in html, txt...

Hey, hey ...
Don't go too fast
but that is excellent !

I would put it otherwise :
STO in an internal format !
There is a transformer to XML / HTML / TXT...
One remark though Java XML apps are deadly slow on small PC's

>
>
>>> - services shared between TestCases
>>
>>
>> Could you give a Practal example.
>
> Database connection.  It's costly and if you have several tests,
> connecting to the database for each test is really costly.  The idea is
> to set up a pool of resources (database, RMI or Corba connection, JNDI)
> at the beginning of the run and let tests aquire the resource when they
> need it.
>

Well there is Pro's & Con's to it
Quickly said I see more Con's than Pro's
Bcoze I also run the ALL tests at nights so I don't give a shit to
recreate a JDBConnection every time eventhough it takes ages !


> All these modifications cannot be done without altering the framework
> itself and developing new runners.  Because the JUnit managment won't
> ever accept all these idea (I know, I asked), the best way is to start
> something from scratch.
>
> -Vladimir

Well Vladimir,
It's always hard to see your own kids grow up & move away.
Must be the same for them, he :-D


C ya,

Thomas,

--


rue J. Wytsman 62
B - 1050 Brussels
Belgium
Tel. : +32 (0)2 742 05 94 (GMT+1)
yahoo-id : smetsthomas

#3439 From: emeade@...
Date: Tue Dec 4, 2001 3:22 am
Subject: Re: New poll for junit
geektank
Send Email Send Email
 
The list owner (me) addressed this in:

http://groups.yahoo.com/group/junit/message/3403

The email of the person who created the poll was adultstaffing I
didn't pay much attention as I deleted the poll and kicked them off
the list, I believe the full email address was
adultstaffing@....

This list is unmoderated.

--
Erik Meade             emeade@...
Senior Consultant      Object Mentor, Inc.
http://www.junit.org


--- In junit@y..., Sean Higgins <seanh@r...> wrote:
> Is this spam or just seriously off-topic or what?
> Anybody else find this offensive?
> Where did it come from - is it from Yahoo?
> How do you stop this sort of abuse?
> (No, I dont want to start a thread about it,
> I'd rather the list moderator - if there is one -
> could filter out Stuff Like This).
>
> Sean Higgins
> RPK New Zealand Ltd
> (Normally silent lurker.
> You haven't heard from me before because so far
> I've got most of the answers I need just by reading.)
>
> At 03:48 PM 02/12/01 -0000, you wrote:
> >
> >Enter your vote today!  A new poll has been created for the
> >junit group:
> >
> >Are there too many Indians in the
> >United States stealing American born
> >citizens jobs?
> >
> >  o Yes, I am American
> >  o Yes, I am Indian
> >  o Yes
> >  o No, I am Indian
> >  o Undecided
> >
> >
> >To vote, please visit the following web page:
> >
> >http://groups.yahoo.com/group/junit/polls
> >
> >Note: Please do not reply to this message. Poll votes are
> >not collected via email. To vote, you must go to the Yahoo! Groups
> >web site listed above.
> >
> >Thanks!
> >
> >
> >
> >
> >
> >
> >
> >
> >To unsubscribe from this group, send an email to:
> >junit-unsubscribe@y...
> >
> >
> >Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
> >

#3440 From: Robert Sartin <sartin@...>
Date: Tue Dec 4, 2001 5:14 am
Subject: Re: User interface issue
robert_sartin
Send Email Send Email
 
--- Vladimir Bossicard <vladimir@...> wrote:

> You would like to have a TestSuite that generates tests for all
> possible
> values (and you pass this value to the test via a Property object,
> for
> example).  It's fine but may I ask: do you really need to test your
> class with every possibilities?  I don't think so.  You cannot test
> everything (imagine if you want to test a drawing program with
> endless possibilities).

There are often situations where it is possible to automatically
generate useful tests. For example, I have a domain-specific language
that configures our product. Statements in the language are allowed in
fairly unconstrained order. There are dependencies between the
statements. Nonetheless, the order of the statements should not affect
the resulting configuration. We found it valuable to write tests that
would permute valid code and verify it compiled to the same result. Of
course, we decided to do it all in one testMethod() because that's the
easier way to configure it. This argument assumes there is only one way
to write tests and that any way that write either more or fewer tests
is wrong. That's simply not the case. JUnit, despite its name, is quite
usable for writing larger scale tests and even for automating tests.
Why not help it be a more complete framework rather than argue it
should not grow because "real" unit tests wouldn't need a proposed
enhancement?

I have another example of automated tests, but I can't remember the
details. In this instance, we actually wrote a setUp() method that
created multiple instance of the TestCase with different
configurations, and ran into the naming problem. Our workaround to the
JUnit confounding of test name with method name was to make sure all of
our assertions include a message that indicates which test
configuration is being used.

Regards,

Rob



__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com

#3441 From: "Layla Barrit" <lbarrit@...>
Date: Tue Dec 4, 2001 5:28 am
Subject: Re: Help
lxb61
Send Email Send Email
 
Thank you so much. Actually The Junit primer was one of the few test cases I found on the net :).
 
Layla 
 
----- Original Message -----
From: Mike Clark
Sent: Saturday, December 01, 2001 4:24 PM
To: junit@yahoogroups.com
Subject: Re: [junit] Help
 
Layla Barrit wrote:

>
> Hello,I am looking for Junit code examples for a research experiment.
> I will be grateful to anyone of you who can provide me with test cases
> implemented using Junit and the code it tests.Thank you for your
> help.

The JUnit Primer (http://www.clarkware.com/articles/JUnitPrimer.html)
includes example source code.

Hope this helps.

Mike

--
Mike Clark
Clarkware Consulting, Inc.
http://www.clarkware.com
720.851.2014



------------------------ Yahoo! Groups Sponsor ---------------------~-->
See What You've Been Missing!
Amazing Wireless Video Camera.
Click here
http://us.click.yahoo.com/75YKVC/7.PDAA/ySSFAA/NhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
junit-unsubscribe@yahoogroups.com


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



#3442 From: Vladimir Bossicard <vladimir@...>
Date: Tue Dec 4, 2001 6:31 am
Subject: Re: User interface issue
vbossica
Send Email Send Email
 
> This argument assumes there is only one way
> to write tests and that any way that write either more or fewer tests
> is wrong.


That was absolutely not my point (I added "IMHO" on purpose).  Sometimes
writing one test is enough, sometimes writing 10,000 tests is not
enough.  It depends on the complexity of the method you test and your
confidence in that method.

In your case, if you have 20 statements, you have 2.43e18 possible
permutations (let's take the simpliest case where you only permute 20
different statements).  Maybe you will find useful to test all
permutations (I have nothing against it), if you have 40 rules and want
to all 8.15e47 permuations it's also fine with me.  But I don't think
that that it's realistic to test all and every permutation, but that's
only _my_ point of view.  If you think that you need total confidence
and your computer is fast enough, go ahead and test every case.  I
really don't have anything against that.

> That's simply not the case. JUnit, despite its name, is quite
> usable for writing larger scale tests and even for automating tests.


And that's what I proposed in my answer.  I simply pointed out that
sometimes testing _all_ possibilities doesn't make (much) sense and that
you can be reasonably confident by writing only a few tests (how many is
*a few* is up to you).


> Why not help it be a more complete framework rather than argue it
> should not grow because "real" unit tests wouldn't need a proposed
> enhancement?


Have I said that JUnit should not grow???  Surely not!!!  What I
strongly think is that "if there is a need, it should be addressed,
either directly or indirectly".  "Real" unit tests often need more than
the standard JUnit, and I would like to hear the problems of those users
users more often on this newsgroup.

> Our workaround to the JUnit confounding of test name with method name

> was to make sure all of
> our assertions include a message that indicates which test
> configuration is being used.


That was my point in another message, explaining the mean of the "name"
attribute in the TestCase class.  It was simply an explanation nothing
more.  I think that sometimes explaining the framework can be helpful,
but it's once again my point of view :-)


-Vladimir

--
Vladimir Bossicard
www.bossicard.com

#3443 From: Thomas SMETS <tsmets@...>
Date: Mon Dec 3, 2001 7:54 pm
Subject: Re: Help
smetsthomas
Send Email Send Email
 
Yeap
Mike is a bit the spiritual father of everybody beginning with JUnit...

Tx dad
:-D

Thomas,


Layla Barrit wrote:

> Thank you so much. Actually The Junit primer was one of the few test
> cases I found on the net :).
>
>
>
> Layla
>
>
>
>     ----- Original Message -----
>
>     From: Mike Clark
>
>     Sent: Saturday, December 01, 2001 4:24 PM
>
>     To: junit@yahoogroups.com
>
>     Subject: Re: [junit] Help
>
>
>
>     Layla Barrit wrote:
>
>      >
>      > Hello,I am looking for Junit code examples for a research experiment.
>      > I will be grateful to anyone of you who can provide me with test
>     cases
>      > implemented using Junit and the code it tests.Thank you for your
>      > help.
>
>     The JUnit Primer (http://www.clarkware.com/articles/JUnitPrimer.html)
>     includes example source code.
>
>     Hope this helps.
>
>     Mike
>
>     --
>     Mike Clark
>     Clarkware Consulting, Inc.
>     http://www.clarkware.com
>     720.851.2014
>
>
>
>
>     To unsubscribe from this group, send an email to:
>     junit-unsubscribe@yahoogroups.com
>
>
>     Your use of Yahoo! Groups is subject to
>     http://docs.yahoo.com/info/terms/
>
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
>
<http://rd.yahoo.com/M=178320.1681224.3270152.1261774/D=egroupweb/S=1705007181:H\
M/A=879172/R=0/*http://www.fastweb.com/ib/yahoo-75f>
>
>
>
> To unsubscribe from this group, send an email to:
> junit-unsubscribe@yahoogroups.com
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/>.


--


rue J. Wytsman 62
B - 1050 Brussels
Belgium
Tel. : +32 (0)2 742 05 94 (GMT+1)
yahoo-id : smetsthomas

#3444 From: "Ian Lim" <mallim@...>
Date: Tue Dec 4, 2001 11:20 am
Subject: Re: JUnit Tests and Business Rules
mallim_sg
Send Email Send Email
 
Hi

In this case, are we talking about rules engines here?
If affirmative, the two URLs below might be of some help.
Personally, I have not managed to try the two products below

JEOPS: http://www.sf.net/proejcts/jeops
Mandarax: http://www.mandarax.org/

Sincerely
==========
Ian Lim
email: mallim_sg@...
homepage: http://www.webappcabaret.com/mallim
Singapore Java XP User Group:
http://www.jadcentral.com/jugcentral/jug.jsp?jug_ID=106

#3445 From: <evought@...>
Date: Tue Dec 4, 2001 5:05 pm
Subject: Re: User interface issue
eric_vought
Send Email Send Email
 
In past situations, I've addressed the computational problem by having a
decent random number library available that can generate good quality
psuedo-random numbers from a couple of distributions. In something like
the permutations case, I would have static test cases that always ran in
one particular order, then I would have a testcase which would select,
say, one hundred additional randomly selected permutations for each test
run. Over the course of the project, a large portion of the problem space
would be tested.

For the naming problem, I used log files. I wasn't using JUnit back then
(or Java), but the framework I was using had the same problem. I logged
the starting seed at the beginning of the test and logged the
inputs at the beginning of each iteration. If it failed, I could reproduce
the entire run in a debugger, or just copy the inputs (vectors
representing cartographic data in my case) from an iteration out of the
log file into a new input file to examine the failure. I also got to
generating completely random data sets at some point.

Now, with JUnit, I have a LoggingTestCase base class that allows me to
collect logging information fairly easily from my testcases. I don't
normally rerun the same testcase with different parameters; rather, I just
have a loop inside the testcase. This makes a single testcase "heavier" in
some sense, but, in another sense, it doesn't. Because I have a separate
static test case which verifies that the logic works in some order or
with the boundary cases, the  iterating testcase is only testing one
discrete thing- that permutations of the same process also work.
Typically, the iterating testcase is no more likely to fail.

On Mon, 3 Dec 2001, Vladimir Bossicard wrote:

> > This argument assumes there is only one way
> > to write tests and that any way that write either more or fewer tests
> > is wrong.
>
>
> That was absolutely not my point (I added "IMHO" on purpose).  Sometimes
> writing one test is enough, sometimes writing 10,000 tests is not
> enough.  It depends on the complexity of the method you test and your
> confidence in that method.
>
> In your case, if you have 20 statements, you have 2.43e18 possible
> permutations (let's take the simpliest case where you only permute 20
> different statements).  Maybe you will find useful to test all
> permutations (I have nothing against it), if you have 40 rules and want
> to all 8.15e47 permuations it's also fine with me.  But I don't think
> that that it's realistic to test all and every permutation, but that's
> only _my_ point of view.  If you think that you need total confidence
> and your computer is fast enough, go ahead and test every case.  I
> really don't have anything against that.
>
> > That's simply not the case. JUnit, despite its name, is quite
> > usable for writing larger scale tests and even for automating tests.
>
>
> And that's what I proposed in my answer.  I simply pointed out that
> sometimes testing _all_ possibilities doesn't make (much) sense and that
> you can be reasonably confident by writing only a few tests (how many is
> *a few* is up to you).
>
>
> > Why not help it be a more complete framework rather than argue it
> > should not grow because "real" unit tests wouldn't need a proposed
> > enhancement?
>
>
> Have I said that JUnit should not grow???  Surely not!!!  What I
> strongly think is that "if there is a need, it should be addressed,
> either directly or indirectly".  "Real" unit tests often need more than
> the standard JUnit, and I would like to hear the problems of those users
> users more often on this newsgroup.
>
> > Our workaround to the JUnit confounding of test name with method name
>
> > was to make sure all of
> > our assertions include a message that indicates which test
> > configuration is being used.
>
>
> That was my point in another message, explaining the mean of the "name"
> attribute in the TestCase class.  It was simply an explanation nothing
> more.  I think that sometimes explaining the framework can be helpful,
> but it's once again my point of view :-)
>
>
> -Vladimir
>
>

--
Eric Vought
Chief Technical Officer - QLUE Consulting, Inc.

evought@... toll-free: 888-771-3538  RTP area: 919-816-9901

#3446 From: Mark Derricutt <mark@...>
Date: Wed Dec 5, 2001 1:54 am
Subject: Re: JUnit Tests and Business Rules
talios2k
Send Email Send Email
 
--On Sunday, 2 December 2001 1:05 p.m. -0700 Mike Clark
<mike@...> wrote:

Apologies to all for a long post :)

> This is probably more than is necessary for checking whether a field is
> editable or not, but it does address the 'if' statement for generic
> rule-based systems.  The simplest approach is to simply refactor each test
> into its own method, as you've already pointed out.

Well, in this checking if a field is editable or not (more cell editable in
a large grid), is based upon a set of rules that differ for each cell,
things like "editable if transaction for cell is billable, but not billed,
and settings.autobill is on", and numerous other rules.  And I imagine
there will lots of other places in the code that will use it.

Looking at your Ruleset snippet, I got to thinking, what I want is
something that looks somewhat like a JUnit test, and something, that could
be easily tested with JUnit.

I was also looking at what my code does, looking at objects from the
current HttpSession, obviously, I won't have this at testing time, so I was
thinking, if I construct a Hashtable, and put in the objects from the
session (or at least, the object I use) and pass the hashtable to my rule
to test against, things could work.

I wrote up the following sample/psudo code as well, any thoughts, comments,
or pointers to blatently bad code here?:

// Sample ruleset class, one rule that checks if autoBill is on.
public class WTRecBeanEditable extends RuleSet
{
	 Staff currentStaff = null;
	 Control companyProp = null;

	 public void setUp() {
		 currentStaff = (Staff) ruleInfo.get("currentStaff");
		 companyProp = (Control) ruleInfo.get("companyProp");
	 }

	 public void tearDown() {
		 currentStaff = null;
		 companyProp = null;
	 }

	 public boolean ruleAutoBill()
	 {
		 return companyProp.autoBill;
	 }

}


// The actual class the rule is used in, create a static instance of
// the rule (this might be a bad idea, not sure)

public class WTRecBean {

	 private static RuleSet ruleEditable = new WTRecBeanEditable();

          // insert objects from httpsession into hash, and check rule
          // .checkRule could be overloaded to accept an HttpSession
          // which just copies all attributes everything over to the
          // HashTable for you...

	 public boolean isEditable() {
		 HashTable hash = new HashTable();
		 hash.set("currentStaff", session.get("currentStaff"));
		 hash.set("companyProp", session.get("companyProp"));
		 return ruleEditable.checkRule(hash);
	 }
}

And finally...


// The JUnit testcase to test it all.

public class WTRecTest extends TestCase {

	 Hashtable hash = null;
	 Staff currentStaff = null;
	 Control companyProp = null;

	 public void setup() {
		 Staff currentStaff = new Staff();
		 currentStaff.set(..); // setup staff to known state

		 Control companyProp = new Control();
		 companyProp.set(..);  // setup control to known state

		 HashTable hash = new HashTable();
		 hash.set("currentStaff", currentStaff);
		 hash.set("companyProp", companyProp);
	 }

	 public void tearDown() {
		 currentStaff = null;
		 companyProp = null;
		 hash = null;
	 }


	 public void testEditable() {

		 // Set test specific alterations to staff and control
		 companyProp.setBill(false);

		 RuleSet WTRecBean.ruleEditable = new WTRecBeanEditable();

		 assertTrue(ruleEditable.checkRule(hash));
	 }

}



--
Mark Derricutt                                E-Mail: markd@...
Senior Delphi Developer                                        ICQ: 19348533
Time Disciple Ltd                                http://www.timedisciple.com

             Limitations only serve to give direction to your goals
          Vi de udødelige inviterer dere til å slå dere sammen med oss

#3447 From: Daniel Le Berre <leberre@...>
Date: Wed Dec 5, 2001 1:19 pm
Subject: Junit and the extension mechanism
leberre@...
Send Email Send Email
 
Hi guys,

When I put the junit.jar in the jre/lib/ext directory to get
junit without changing all the users classpath, the
junit.textui.TestRunner does not find my classes.

However, both swingui and awtui TestRunners are working fine.

If I put the junit.jar in my classpath, everything works fine.

I do believe than the problem comes from the use of the default
class loader in testui.TestRunner: when I use the extension
mechanism, only the core classes and the ones in the extension
directory can be found by the default class loader.

Would it be possible to use the custom class loader also for textui
to solve the problem?

	 Daniel
--
               Daniel Le Berre mailto:leberre@...
               Maitre de Conferences,  CRIL,  Universite d'Artois
               http://www.cril.univ-artois.fr/~leberre

#3448 From: "J. B. Rainsberger" <jbr@...>
Date: Wed Dec 5, 2001 2:02 pm
Subject: RE: JUnit Tests and Business Rules
nails762
Send Email Send Email
 
As far as I can recall, it is JSR94. I participated extremely lightly in it,
so please don't expect much from me in the way of details. :) It focused on
fusing the programming interfaces of BEA/WebLogic's rules processing and
Blaze Software's Advisor product.

Take care,
===========================================
J. B. Rainsberger,
Diaspar Software Services Inc.
Software development with Java and XP


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
J.B., where can one find out more about javax.rules?  Is there a JSR you
know of?  Sounds interesting.

Scott Stirling
JRun QA
Macromedia

> -----Original Message-----
> From: J. B. Rainsberger [mailto:jbr@...]
>
>
> This is an excellent suggestion. Business rule processing is slowly
> making its way into Java proper under javax.rules. Until
> then, this is a
> good approach; however...
[snip]


To unsubscribe from this group, send an email to:
junit-unsubscribe@yahoogroups.com


Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#3449 From: <evought@...>
Date: Wed Dec 5, 2001 3:45 pm
Subject: Re: Junit and the extension mechanism
eric_vought
Send Email Send Email
 
When a jar loads from the jre/lib/ext directory, it gets a different
classloader and default security profile then something which loads from
your classpath. This profile prevents it from loading classes from
arbitrary locations. This behavior was a design choice on Sun's part- the
extension loader is intended to support the requirements of your run of
the mill executable jars, not the unusual needs of junit.

The swingui and awtui work fine because they create their own classloader
and it is the same whether or not they are loaded via jre/lib/ext. The
custom classloader, however, has a number of known bugs in it which cause
people problems from time to time. Some folks use the textui specifically
to avoid these problems.

It's probably a better idea to put junit in your classpath. If you are
compiling on several different systems which require different classpaths,
I can give you some hints on how to do this cleanly with ANT.

On Wed, 5 Dec 2001, Daniel Le Berre wrote:

> Hi guys,
>
> When I put the junit.jar in the jre/lib/ext directory to get
> junit without changing all the users classpath, the
> junit.textui.TestRunner does not find my classes.
>
> However, both swingui and awtui TestRunners are working fine.
>
> If I put the junit.jar in my classpath, everything works fine.
>
> I do believe than the problem comes from the use of the default
> class loader in testui.TestRunner: when I use the extension
> mechanism, only the core classes and the ones in the extension
> directory can be found by the default class loader.
>
> Would it be possible to use the custom class loader also for textui
> to solve the problem?
>
>  Daniel
>

--
Eric Vought
Chief Technical Officer - QLUE Consulting, Inc.

evought@... toll-free: 888-771-3538  RTP area: 919-816-9901

#3450 From: "Stevens, Timothy J. (LNG-MBC)" <timothy.j.stevens@...>
Date: Wed Dec 5, 2001 3:48 pm
Subject: JUnit vs. SilkTest
timothy_j_st...
Send Email Send Email
 
There's a possibility that we may be "encouraged" to use SilkTest
here for our testing in the near future, and I'm hoping someone out there
can provide a little more info about it. The list of features on the
software's website isn't very descriptive, and a little real-world knowledge
about the tool would be appreciated.

	 Can anyone compare and contrast the features of SilkTest to JUnit?
What's the deal with their 4Test language? Does SilkTest integrate with a
build control tool like ANT very well?

	 Thanks in advance,

	 -tim

#3451 From: jie.mei@...
Date: Wed Dec 5, 2001 4:41 pm
Subject: JUnit vs. SilkTest
jie.mei@...
Send Email Send Email
 
Hi Tim,

I know Silktest as a (rather awful) functional test tool owned by the
company Segue. How comes that you compare it to JUnit which is an open
source unit testing tool?

Thank you,
Jie




                     "Stevens, Timothy J.
                     (LNG-MBC)"                      An:    
"'junit@yahoogroups.com'" <junit@yahoogroups.com>
                     <timothy.j.stevens@lexis        Kopie:  (Blindkopie: Jie
Mei/mummert/de)
                     nexis.com>                      Thema:  [junit] JUnit vs.
SilkTest

                     05.12.2001 16:48
                     Bitte antworten an junit







            There's a possibility that we may be "encouraged" to use
SilkTest
here for our testing in the near future, and I'm hoping someone out there
can provide a little more info about it. The list of features on the
software's website isn't very descriptive, and a little real-world
knowledge
about the tool would be appreciated.

            Can anyone compare and contrast the features of SilkTest to
JUnit?
What's the deal with their 4Test language? Does SilkTest integrate with a
build control tool like ANT very well?

            Thanks in advance,

            -tim


To unsubscribe from this group, send an email to:
junit-unsubscribe@yahoogroups.com


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

#3452 From: Scott Stirling <sstirling@...>
Date: Wed Dec 5, 2001 5:21 pm
Subject: JUnit and Ant: stack trace filtering
jrun4
Send Email Send Email
 
Hey all,

JUnit provides a feature that allows you to filter stack traces that come
from errors and failures, so that the junit framework method frames don't
clutter up your exception stack traces.

I modified the Ant JUnit task to support this functionality.  Would
appreciate it if a couple more people tried it out before I submit it to
Jakarta.  I've been using it in some of our build projects here with no
problems.  Plus, it might be something people want, but there's no guarantee
it makes it into the main Ant line.

This code is modified from Ant 1.5 source from about two weeks ago, so it
will probably only work with Ant 1.5, but I haven't even tried it with 1.4.
You can jar uvf the classes into your Ant optional.jar, or you may be able
to get it to work by mixing around with the jar file names, but this is
trickier since Ant uses the manifest file to set it's core classpath.

Does this list support attachments?  Or should I just upload the jar (with
source) to the Yahoo group site?

Scott Stirling
JRun QA
Macromedia

Messages 3423 - 3452 of 24385   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help