Not quite. iContract preprosesses code with @pre @post and @invariant
tags and converts it to java code which is then inserted into the class
itself.
Basically it would take this code
/**
* @pre celcius > -273.15
*/
public double convertCelciusToFahrenheit( double celcius ) {
return 9.0/5.0 * celcius + 32.0;
}
and produce this code:
public double convertCelciusToFahrenheit( double celcius ) {
if( !(celcius > -273.15 ) ) {
throw new Error( "precondition failed" );
}
return 9.0/5.0 * celcius + 32.0;
}
It's got nothing to do with unit testing. This isn't a test you can
explicitly run and succeed like a JUnit test. iContract assertions
become part of your code and tells you if someone is using it badly.
It's two complementary but quite orthogonal testing approaches. (And by
the way I am the author of the iContract Ant 1.4 task :)
I realise that declaring complicated unit tests as I suggested in my
previous mail is virtually impossible, since setting up a test and
running it involves a fair amount of code that can't be generalised in
such a way that it fits into javadoc tags. (Unless of course some out-
of-the-box-thinker tells me otherwise).
What we _could_ do is to let XDoclet generate skeletons that
programmers can use as a starting point for their own tests. A lot of
IDEs have this feature built in. This means that if you start editing
these tests, you shouldn't generate skeletons with XDoclet again, as
they will overwrite the modified tests. I realise that this is against
the general XDoclet philosophy, but it could still be useful. Anyone
else think so?
<aslak/>
----- Original Message -----
From: "Ara Abrahamian" <[EMAIL PROTECTED]>
Date: Monday, October 15, 2001 5:07 pm
Subject: RE: [Xdoclet-devel] Re: [Xdoclet-user] xdoclet for JUnit?
> I guess that's what iContract does more or less? Right?
> I'm not a big fan of it, I mean overusing xdoclet is not good :-)
> But it's indeed in xdoclet's boundary.
>
> Ara.
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:xdoclet-
> devel-
> > [EMAIL PROTECTED]] On Behalf Of [EMAIL PROTECTED]
> > Sent: Monday, October 15, 2001 4:01 PM
> > To: Michael Larionov; [EMAIL PROTECTED]; xdoclet-
> > [EMAIL PROTECTED]
> > Subject: [Xdoclet-devel] Re: [Xdoclet-user] xdoclet for JUnit?
> >
> > Hi!
> >
> > Great that you want to do this. I got the understanding you want to
> use
> > XDoclet to write the JUnit test suit classes.
> > What do you think about generating the test cases themselves?
> Something
> > like this:
> >
> > /**
> > * A class that converts temperatures between celcius and fahrenheit
> > *
> > * @junit:superclass junit.framework.TestCase
> > *
> > * @junit:setup
> > * member-type="TemperatureConverter"
> > * member-name="converter"
> > * member-initValue="new TemperatureConverter()"
> > *
> > *
> > */
> > public class TemperatureConverter
> >
> > /**
> > * Do it!
> > *
> > * @param celcius celcius value
> > * @return fahrenheit value
> > * @junit:test
> > * type="equals"
> > * name="35C95F"
> > * description="35 C equals 95 F"
> > * member-name="converter"
> > * params="35"
> > * expected="95"
> > */
> > public double convertCelciusToFahrenheit( double celcius ) {
> > return 9.0/5.0 * celcius + 32.0;
> > }
> > }
> >
> > Then XDoclet could generate something like this:
> >
> >
> > public class TemperatureConverterTest extends
> junit.framework.TestCase{
> >
> > private TemperatureConverter converter;
> >
> > public void setUp() {
> > converter = new TemperatureConverter();
> > }
> >
> > public void testConvertCelciusToFahrenheit35C95F() {
> > assertEquals("35 C equals 95 F", 95,
> > converter.convertCelciusToFahrenheit(35));
> > }
> > }
> >
> >
> > What do you think? I think the challenge is to come up with a
> set of
> > tags that are general enough to declare
> > any kind of tests. -And maybe that's impossible. But if we
> manage to
> do
> > so, it will definitely take XDoclet one step
> > beyond the killer app status it already has. I order everybody
> to have
> > a meaning about this!
> >
> > <aslak/>
> >
> > ----- Original Message -----
> > From: "Michael Larionov" <[EMAIL PROTECTED]>
> > Date: Monday, October 15, 2001 12:39 pm
> > Subject: Re: [Xdoclet-user] xdoclet for JUnit?
> >
> > > I'll give it a shot! If I need any help I am sure I will get it,
> > > right?
> > > Should I move the discussion to the developers list?
> > >
> > > Thanks!
> > >
> > > Michael.
> > >
> > > ----- Original Message -----
> > > From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> > > To: "Michael Larionov" <[EMAIL PROTECTED]>
> > > Cc: "Xdoclet mailing list" <[EMAIL PROTECTED]>
> > > Sent: Saturday, October 13, 2001 8:30 PM
> > > Subject: Re: [Xdoclet-user] xdoclet for JUnit?
> > >
> > >
> > > > Yep, works fine. Should be possible afaik using the
> > > TemplateDoclet. Are
> > > > you going to have a go at this yourself? If not, let me know,
> > > shouldn't> take long.
> > > >
> > > > cheers
> > > > dim
> > > >
> > > > On Sat, 13 Oct 2001, Michael Larionov wrote:
> > > >
> > > > > Well, AFAIK the goal of xdoclet is to reduce the double
> > > maintenance.> > The case exists in JUnit test cases which have to
> > > be grouped into
> > > > > the test suites, and in that case you need to create the
> > > special suite
> > > > > classes
> > > > > which include the names of test cases. This sounds for me
> like a
> > > > > double-maintenance.
> > > > >
> > > > > The way I would use xdoclet for test cases is that I would not
> > > create> > test suite classes. Instead I would include
> @junit:test-
> > > case doclet in
> > > the
> > > > > test
> > > > > and have xunit generate the suite classes for me.
> > > > >
> > > > > One of the way to do that is to create suites for every
> package> > containing
> > > > > test cases.
> > > > > The suite has to invoke suites of the subclasses. Like if I
> > > have the
> > > > > following hierarchy
> > > > > of tests:
> > > > >
> > > > > com.zzz.test.user : UserTest, UserDataTest, MMTest
> > > > > com.zzz.test.user.customer: CustomerTest, DateOfBirthTest,
> > > KKKTest,> > com.zzz.test.business: BusinessTest, BusinessDataTest,
> > > LLLTest
> > > > >
> > > > > xdoclet will generate the folloving classes:
> > > > >
> > > > > com.zzz.test.user.customer.TestingSuite invoking CustomerTest,
> > > > > DateOfBirthTest, KKKTest,
> > > > > com.zzz.test.user.TestingSuite invoking UserTest,
> > > UserDataTest, MMTest
> > > as
> > > > > well as
> > > > > com.zzz.test.user.customer.TestingSuite
> > > > > com.zzz.test.business.TestingSuite invoking BusinessTest,
> > > BusinessDataTest,
> > > > > LLLTest
> > > > > com.zzz.test.TestingSuite invoking
> > > com.zzz.test.user.TestingSuite and
> > > > > com.zzz.test.business.TestingSuite
> > > > >
> > > > > By "invoking" I mean in the method "suite" you add a line:
> > > > > suite.addTest(new TestSuite(UserTest.class));
> > > > > or
> > > > >
> > >
> suite.addTest(com.zzz.test.user.customer.TestingSuite.suite());> >
> > > > > If this feature is useful for everybody I can participate in
> > > developmentof
> > > > > it.
> > > > >
> > > > > Michael.
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Ara Abrahamian" <[EMAIL PROTECTED]>
> > > > > To: "'Michael Larionov'" <[EMAIL PROTECTED]>;
> "'Xdoclet
> > > mailing
> > > > > list'" <[EMAIL PROTECTED]>
> > > > > Sent: Saturday, October 13, 2001 1:18 PM
> > > > > Subject: RE: [Xdoclet-user] xdoclet for JUnit?
> > > > >
> > > > >
> > > > > > What exactly do you want it to do?
> > > > > >
> > > > > > Ara.
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: [EMAIL PROTECTED]
> > > [mailto:xdoclet-user-
> > > > > > > [EMAIL PROTECTED]] On Behalf Of Michael Larionov
> > > > > > > Sent: Saturday, October 13, 2001 6:37 PM
> > > > > > > To: Xdoclet mailing list
> > > > > > > Subject: [Xdoclet-user] xdoclet for JUnit?
> > > > > > >
> > > > > > > Hi ,
> > > > > > >
> > > > > > > I am just wondering if someone is developing xdoclet for
> > > JUnit test
> > > > > > cases.
> > > > > > >
> > > > > > > Thanks!
> > > > > > >
> > > > > > > Michael.
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > Xdoclet-user mailing list
> > > > > > > [EMAIL PROTECTED]
> > > > > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> > > > > >
> > > > > >
> > > > > > _________________________________________________________
> > > > > > Do You Yahoo!?
> > > > > > Get your free @yahoo.com address at http://mail.yahoo.com
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Xdoclet-user mailing list
> > > > > [EMAIL PROTECTED]
> > > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Xdoclet-user mailing list
> > > > [EMAIL PROTECTED]
> > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> > >
> > >
> > > _______________________________________________
> > > Xdoclet-user mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> > >
> >
> >
> > _______________________________________________
> > Xdoclet-devel mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
>
>
>
> _________________________________________________________
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel