You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Nathan Beyer <nb...@gmail.com> on 2006/11/29 04:26:56 UTC

[general] JUnit consistency, practices

There is a large amount of inconsistency across the tests and I'd like
to lobby for cleaning them up as much as possible. I'm of the opinion
that test code should be clean, simple and transparent. Here are some
of the more noticeable items that I'd like to cleanup.

* Empty setUp/teardown methods - There are a number of tests that
override setUp and/or teardown methods, but are either empty or just
call the super implementation.

* Singleton suite methods - There are some tests that contain a static
"suite" method that creates a TestSuite and adds one test (the test
class it's declared in). Are there any practical uses for these
methods? TestSuites are for grouping together tests to treat them as
one unit. Since these suites are just one test, it doesn't seem to
provide much value.

* main method launching text runner - There are some tests that
contain "main" methods which run the enclosing test via a JUnit text
runner. Most IDEs have built-in support for JUnit and can launch any
test arbitrarily and Ant can do the same thing. Does anyone launch
tests via these methods?

My proposal would be to clean up these inconsistencies by eliminating
them, but what does everyone else think?

-Nathan

Re: [general] JUnit consistency, practices

Posted by Alexei Zakharov <al...@gmail.com>.
> Just FYI: junit4 provides cmd-line support for running single test
> method. So the equivalent to the above is:
> $ java -cp junit-4.0.jar junit.textui.TestRunner -m MyTest.testReallyHotIssue

Cool! Thanks. I didn't know this. It seems ant junit task doesn't
support this (at least for 1.6.5). I've also noticed you are using
junit v4.0 here.

Regards,

2006/11/30, Alexey Varlamov <al...@gmail.com>:
> 2006/11/29, Alexei Zakharov <al...@gmail.com>:
> > Hi,
> >
> > > * Empty setUp/teardown methods
> >
> > +1
> >
> > > * Singleton suite methods - There are some tests that contain a static
> > > "suite" method that creates a TestSuite and adds one test (the test
> > > class it's declared in). Are there any practical uses for these
> > > methods? TestSuites are for grouping together tests to treat them as
> > > one unit. Since these suites are just one test, it doesn't seem to
> > > provide much value.
> >
> > Well, suite() method is very useful when you are trying to find the
> > reason of the individual test method failure. It is simpler to debug
> > (add debug logs for example) to a single code path rather than to run
> > through 60 tests methods before you reach the desired break point. If
> > you have the suite() method all you need is just to add the following
> > line:
> > suite.addTest(new MyTest("testReallyHotIssue"));
>
> Just FYI: junit4 provides cmd-line support for running single test
> method. So the equivalent to the above is:
> $ java -cp junit-4.0.jar junit.textui.TestRunner -m MyTest.testReallyHotIssue
>
> > So I would suggest to leave suites as it is for now.
> >
> > > * main method launching text runner
> >
> > I'm neutral here. We (probably) can always run
> >  java junit.textui.TestRunner MyClass
> > instead of
> > java MyClass.
> >
> > Thanks,
> >
> > 2006/11/29, Nathan Beyer <nb...@gmail.com>:
> > > There is a large amount of inconsistency across the tests and I'd like
> > > to lobby for cleaning them up as much as possible. I'm of the opinion
> > > that test code should be clean, simple and transparent. Here are some
> > > of the more noticeable items that I'd like to cleanup.
> > >
> > > * Empty setUp/teardown methods - There are a number of tests that
> > > override setUp and/or teardown methods, but are either empty or just
> > > call the super implementation.
> > >
> > > * Singleton suite methods - There are some tests that contain a static
> > > "suite" method that creates a TestSuite and adds one test (the test
> > > class it's declared in). Are there any practical uses for these
> > > methods? TestSuites are for grouping together tests to treat them as
> > > one unit. Since these suites are just one test, it doesn't seem to
> > > provide much value.
> > >
> > > * main method launching text runner - There are some tests that
> > > contain "main" methods which run the enclosing test via a JUnit text
> > > runner. Most IDEs have built-in support for JUnit and can launch any
> > > test arbitrarily and Ant can do the same thing. Does anyone launch
> > > tests via these methods?
> > >
> > > My proposal would be to clean up these inconsistencies by eliminating
> > > them, but what does everyone else think?

-- 
Alexei Zakharov,
Intel Enterprise Solutions Software Division

Re: [general] JUnit consistency, practices

Posted by Alexey Varlamov <al...@gmail.com>.
2006/11/29, Alexei Zakharov <al...@gmail.com>:
> Hi,
>
> > * Empty setUp/teardown methods
>
> +1
>
> > * Singleton suite methods - There are some tests that contain a static
> > "suite" method that creates a TestSuite and adds one test (the test
> > class it's declared in). Are there any practical uses for these
> > methods? TestSuites are for grouping together tests to treat them as
> > one unit. Since these suites are just one test, it doesn't seem to
> > provide much value.
>
> Well, suite() method is very useful when you are trying to find the
> reason of the individual test method failure. It is simpler to debug
> (add debug logs for example) to a single code path rather than to run
> through 60 tests methods before you reach the desired break point. If
> you have the suite() method all you need is just to add the following
> line:
> suite.addTest(new MyTest("testReallyHotIssue"));

Just FYI: junit4 provides cmd-line support for running single test
method. So the equivalent to the above is:
$ java -cp junit-4.0.jar junit.textui.TestRunner -m MyTest.testReallyHotIssue

> So I would suggest to leave suites as it is for now.
>
> > * main method launching text runner
>
> I'm neutral here. We (probably) can always run
>  java junit.textui.TestRunner MyClass
> instead of
> java MyClass.
>
> Thanks,
>
> 2006/11/29, Nathan Beyer <nb...@gmail.com>:
> > There is a large amount of inconsistency across the tests and I'd like
> > to lobby for cleaning them up as much as possible. I'm of the opinion
> > that test code should be clean, simple and transparent. Here are some
> > of the more noticeable items that I'd like to cleanup.
> >
> > * Empty setUp/teardown methods - There are a number of tests that
> > override setUp and/or teardown methods, but are either empty or just
> > call the super implementation.
> >
> > * Singleton suite methods - There are some tests that contain a static
> > "suite" method that creates a TestSuite and adds one test (the test
> > class it's declared in). Are there any practical uses for these
> > methods? TestSuites are for grouping together tests to treat them as
> > one unit. Since these suites are just one test, it doesn't seem to
> > provide much value.
> >
> > * main method launching text runner - There are some tests that
> > contain "main" methods which run the enclosing test via a JUnit text
> > runner. Most IDEs have built-in support for JUnit and can launch any
> > test arbitrarily and Ant can do the same thing. Does anyone launch
> > tests via these methods?
> >
> > My proposal would be to clean up these inconsistencies by eliminating
> > them, but what does everyone else think?
>
>
> --
> Alexei Zakharov,
> Intel Enterprise Solutions Software Division
>

Re: [general] JUnit consistency, practices

Posted by Alexei Zakharov <al...@gmail.com>.
Hi,

> * Empty setUp/teardown methods

+1

> * Singleton suite methods - There are some tests that contain a static
> "suite" method that creates a TestSuite and adds one test (the test
> class it's declared in). Are there any practical uses for these
> methods? TestSuites are for grouping together tests to treat them as
> one unit. Since these suites are just one test, it doesn't seem to
> provide much value.

Well, suite() method is very useful when you are trying to find the
reason of the individual test method failure. It is simpler to debug
(add debug logs for example) to a single code path rather than to run
through 60 tests methods before you reach the desired break point. If
you have the suite() method all you need is just to add the following
line:
suite.addTest(new MyTest("testReallyHotIssue"));
So I would suggest to leave suites as it is for now.

> * main method launching text runner

I'm neutral here. We (probably) can always run
 java junit.textui.TestRunner MyClass
instead of
java MyClass.

Thanks,

2006/11/29, Nathan Beyer <nb...@gmail.com>:
> There is a large amount of inconsistency across the tests and I'd like
> to lobby for cleaning them up as much as possible. I'm of the opinion
> that test code should be clean, simple and transparent. Here are some
> of the more noticeable items that I'd like to cleanup.
>
> * Empty setUp/teardown methods - There are a number of tests that
> override setUp and/or teardown methods, but are either empty or just
> call the super implementation.
>
> * Singleton suite methods - There are some tests that contain a static
> "suite" method that creates a TestSuite and adds one test (the test
> class it's declared in). Are there any practical uses for these
> methods? TestSuites are for grouping together tests to treat them as
> one unit. Since these suites are just one test, it doesn't seem to
> provide much value.
>
> * main method launching text runner - There are some tests that
> contain "main" methods which run the enclosing test via a JUnit text
> runner. Most IDEs have built-in support for JUnit and can launch any
> test arbitrarily and Ant can do the same thing. Does anyone launch
> tests via these methods?
>
> My proposal would be to clean up these inconsistencies by eliminating
> them, but what does everyone else think?


-- 
Alexei Zakharov,
Intel Enterprise Solutions Software Division

Re: [general] JUnit consistency, practices

Posted by "Geir Magnusson Jr." <ge...@pobox.com>.

Nathan Beyer wrote:
> There is a large amount of inconsistency across the tests and I'd like
> to lobby for cleaning them up as much as possible. I'm of the opinion
> that test code should be clean, simple and transparent. Here are some
> of the more noticeable items that I'd like to cleanup.
> 
> * Empty setUp/teardown methods - There are a number of tests that
> override setUp and/or teardown methods, but are either empty or just
> call the super implementation.

+1

> 
> * Singleton suite methods - There are some tests that contain a static
> "suite" method that creates a TestSuite and adds one test (the test
> class it's declared in). Are there any practical uses for these
> methods? TestSuites are for grouping together tests to treat them as
> one unit. Since these suites are just one test, it doesn't seem to
> provide much value.

0 - if people use them...

> 
> * main method launching text runner - There are some tests that
> contain "main" methods which run the enclosing test via a JUnit text
> runner. Most IDEs have built-in support for JUnit and can launch any
> test arbitrarily and Ant can do the same thing. Does anyone launch
> tests via these methods?

I'm not in favor of removing for reasons indicated earlier

geir

> 
> My proposal would be to clean up these inconsistencies by eliminating
> them, but what does everyone else think?
> 
> -Nathan

Re: [general] JUnit consistency, practices

Posted by Stepan Mishura <st...@gmail.com>.
On 11/29/06, Nathan Beyer wrote:
>
> There is a large amount of inconsistency across the tests and I'd like
> to lobby for cleaning them up as much as possible. I'm of the opinion
> that test code should be clean, simple and transparent. Here are some
> of the more noticeable items that I'd like to cleanup.
>
> * Empty setUp/teardown methods - There are a number of tests that
> override setUp and/or teardown methods, but are either empty or just
> call the super implementation.


+1 for cleaning

* Singleton suite methods - There are some tests that contain a static
> "suite" method that creates a TestSuite and adds one test (the test
> class it's declared in). Are there any practical uses for these
> methods? TestSuites are for grouping together tests to treat them as
> one unit. Since these suites are just one test, it doesn't seem to
> provide much value.


+1 for cleaning

* main method launching text runner - There are some tests that
> contain "main" methods which run the enclosing test via a JUnit text
> runner. Most IDEs have built-in support for JUnit and can launch any
> test arbitrarily and Ant can do the same thing. Does anyone launch
> tests via these methods?


Sometimes I launch them via "main" method so I'd like to have it in tests.

Thanks,
Stepan.

My proposal would be to clean up these inconsistencies by eliminating
> them, but what does everyone else think?
>
> -Nathan
>

Re: [general] JUnit consistency, practices

Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
Absolutely - if there are people that are against it, don't do it.

geir


Alexei Fedotov wrote:
> Let me clarify my point a bit - I don't think we should remove main()
> from all tests now having (-1) people aboard. This is not a big deal
> anyway compared to 96 open JIRA issues on Swing.
> 
> 
> On 11/29/06, Paulex Yang <pa...@gmail.com> wrote:
>> Mark Hindess wrote:
>> > On 29 November 2006 at 20:34, "Ivan Popov" <iv...@gmail.com> 
>> wrote:
>> >
>> >> Alexei,
>> >>
>> >> I agree that it is still possible to run JUnit tests from command line
>> >> even without having main() in the code. But I think it is easier to
>> >> run test by convenient way
>> >>
>> >>   $ java -cp junit.jar TestClass
>> >>
>> >> rather than in a more complex manner
>> >>
>> >>   $ java -cp junit.jar junit.textui.TestRunner TestClass
>> >>
>> >> Actually, I constantly forget the right spelling of the full class
>> >> name for TestRunner class and have to look into JUnit doc to specify
>> >> proper name for such a command line.
>> >>
>> >> Also, it would be inconvenient if
>> >> someone runs test from an IDE that does not support JUnit environment,
>> >> but launches test as a usual Java application.
>> >>
>> >> I don't insist on adding main() to each JUnit testcase, but I see no
>> >> reason for removing this functionality from those test where it
>> >> already exists.
>> >>
>> >
>> > Whatever we do, main() should either be in all tests or none.  
>> Having it
>> > in only a subset is *much* too confusing.
>> >
>> > I don't care if we have main() in testcases or not.  (I personally will
>> > never use it and don't find remembering[0] the junit test runner 
>> class.)
>> >
>> +1 to keep a consistent style.
>> > Regards,
>> >  Mark.
>> >
>> > [0] I remember it by writing it in a shell script because I have a
>> > terrible memory.
>>
>> > Thanks.
>> > Ivan
>> >
>> > On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
>> >
>> >>> Ivan, Stepan,
>> >>>
>> >>> I personally set +1 for removing main() method. Any script or command
>> >>> line can be trivially modified to launch JUnit tests without main()
>> >>> method: one should just add junit.textui.TestRunner class before a
>> >>> test class name.
>> >>>
>> >>> $ java -cp junit.jar junit.textui.TestRunner TestClass
>> >>>
>> >>> I'm writing this trivial thing here because during our work on class
>> >>> library test enabling it was FAQ N1 for all C/C++ developers.
>> >>>
>> >>> Note, any JUnit test won't work without junit.jar anyway. If you have
>> >>> junit.jar, you have a standard test runner, which is also quite
>> >>> lightweight.
>> >>>
>> >>> --
>> >>> Thank you,
>> >>> Alexei
>> >>>
>> >>> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
>> >>>
>> >>>> -1 for removing main().
>> >>>>
>> >>>> I often run individual tests from command line or using scripts and
>> >>>> it's easier to launch them as a usual Java application. Also, this
>> >>>> facilitates creating separate bundle with test to attach to a bug
>> >>>> report or send to other people, who can just run it from command 
>> line
>> >>>> or use script with the all required options already specified, 
>> instead
>> >>>> of setting IDE for this test.
>> >>>>
>> >>>> Thanks.
>> >>>> Ivan
>> >>>>
>> >>>> On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
>> >>>>
>> >>>>> There is a large amount of inconsistency across the tests and 
>> I'd like
>> >>>>> to lobby for cleaning them up as much as possible. I'm of the 
>> opinion
>> >>>>> that test code should be clean, simple and transparent. Here are 
>> some
>> >>>>> of the more noticeable items that I'd like to cleanup.
>> >>>>>
>> >>>>> * Empty setUp/teardown methods - There are a number of tests that
>> >>>>> override setUp and/or teardown methods, but are either empty or 
>> just
>> >>>>> call the super implementation.
>> >>>>>
>> >>>>> * Singleton suite methods - There are some tests that contain a 
>> static
>> >>>>> "suite" method that creates a TestSuite and adds one test (the test
>> >>>>> class it's declared in). Are there any practical uses for these
>> >>>>> methods? TestSuites are for grouping together tests to treat 
>> them as
>> >>>>> one unit. Since these suites are just one test, it doesn't seem to
>> >>>>> provide much value.
>> >>>>>
>> >>>>> * main method launching text runner - There are some tests that
>> >>>>> contain "main" methods which run the enclosing test via a JUnit 
>> text
>> >>>>> runner. Most IDEs have built-in support for JUnit and can launch 
>> any
>> >>>>> test arbitrarily and Ant can do the same thing. Does anyone launch
>> >>>>> tests via these methods?
>> >>>>>
>> >>>>> My proposal would be to clean up these inconsistencies by 
>> eliminating
>> >>>>> them, but what does everyone else think?
>> >>>>>
>> >>>>> -Nathan
>> >>>>>
>> >>>>>
>> >
>> >
>> >
>> >
>>
>>
>> -- 
>> Paulex Yang
>> China Software Development Lab
>> IBM
>>
>>
>>
> 
> 

Re: [general] JUnit consistency, practices

Posted by Alexei Fedotov <al...@gmail.com>.
Let me clarify my point a bit - I don't think we should remove main()
from all tests now having (-1) people aboard. This is not a big deal
anyway compared to 96 open JIRA issues on Swing.


On 11/29/06, Paulex Yang <pa...@gmail.com> wrote:
> Mark Hindess wrote:
> > On 29 November 2006 at 20:34, "Ivan Popov" <iv...@gmail.com> wrote:
> >
> >> Alexei,
> >>
> >> I agree that it is still possible to run JUnit tests from command line
> >> even without having main() in the code. But I think it is easier to
> >> run test by convenient way
> >>
> >>   $ java -cp junit.jar TestClass
> >>
> >> rather than in a more complex manner
> >>
> >>   $ java -cp junit.jar junit.textui.TestRunner TestClass
> >>
> >> Actually, I constantly forget the right spelling of the full class
> >> name for TestRunner class and have to look into JUnit doc to specify
> >> proper name for such a command line.
> >>
> >> Also, it would be inconvenient if
> >> someone runs test from an IDE that does not support JUnit environment,
> >> but launches test as a usual Java application.
> >>
> >> I don't insist on adding main() to each JUnit testcase, but I see no
> >> reason for removing this functionality from those test where it
> >> already exists.
> >>
> >
> > Whatever we do, main() should either be in all tests or none.  Having it
> > in only a subset is *much* too confusing.
> >
> > I don't care if we have main() in testcases or not.  (I personally will
> > never use it and don't find remembering[0] the junit test runner class.)
> >
> +1 to keep a consistent style.
> > Regards,
> >  Mark.
> >
> > [0] I remember it by writing it in a shell script because I have a
> > terrible memory.
>
> > Thanks.
> > Ivan
> >
> > On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
> >
> >>> Ivan, Stepan,
> >>>
> >>> I personally set +1 for removing main() method. Any script or command
> >>> line can be trivially modified to launch JUnit tests without main()
> >>> method: one should just add junit.textui.TestRunner class before a
> >>> test class name.
> >>>
> >>> $ java -cp junit.jar junit.textui.TestRunner TestClass
> >>>
> >>> I'm writing this trivial thing here because during our work on class
> >>> library test enabling it was FAQ N1 for all C/C++ developers.
> >>>
> >>> Note, any JUnit test won't work without junit.jar anyway. If you have
> >>> junit.jar, you have a standard test runner, which is also quite
> >>> lightweight.
> >>>
> >>> --
> >>> Thank you,
> >>> Alexei
> >>>
> >>> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> >>>
> >>>> -1 for removing main().
> >>>>
> >>>> I often run individual tests from command line or using scripts and
> >>>> it's easier to launch them as a usual Java application. Also, this
> >>>> facilitates creating separate bundle with test to attach to a bug
> >>>> report or send to other people, who can just run it from command line
> >>>> or use script with the all required options already specified, instead
> >>>> of setting IDE for this test.
> >>>>
> >>>> Thanks.
> >>>> Ivan
> >>>>
> >>>> On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> >>>>
> >>>>> There is a large amount of inconsistency across the tests and I'd like
> >>>>> to lobby for cleaning them up as much as possible. I'm of the opinion
> >>>>> that test code should be clean, simple and transparent. Here are some
> >>>>> of the more noticeable items that I'd like to cleanup.
> >>>>>
> >>>>> * Empty setUp/teardown methods - There are a number of tests that
> >>>>> override setUp and/or teardown methods, but are either empty or just
> >>>>> call the super implementation.
> >>>>>
> >>>>> * Singleton suite methods - There are some tests that contain a static
> >>>>> "suite" method that creates a TestSuite and adds one test (the test
> >>>>> class it's declared in). Are there any practical uses for these
> >>>>> methods? TestSuites are for grouping together tests to treat them as
> >>>>> one unit. Since these suites are just one test, it doesn't seem to
> >>>>> provide much value.
> >>>>>
> >>>>> * main method launching text runner - There are some tests that
> >>>>> contain "main" methods which run the enclosing test via a JUnit text
> >>>>> runner. Most IDEs have built-in support for JUnit and can launch any
> >>>>> test arbitrarily and Ant can do the same thing. Does anyone launch
> >>>>> tests via these methods?
> >>>>>
> >>>>> My proposal would be to clean up these inconsistencies by eliminating
> >>>>> them, but what does everyone else think?
> >>>>>
> >>>>> -Nathan
> >>>>>
> >>>>>
> >
> >
> >
> >
>
>
> --
> Paulex Yang
> China Software Development Lab
> IBM
>
>
>


-- 
Thank you,
Alexei

Re: [general] JUnit consistency, practices

Posted by Paulex Yang <pa...@gmail.com>.
Mark Hindess wrote:
> On 29 November 2006 at 20:34, "Ivan Popov" <iv...@gmail.com> wrote:
>   
>> Alexei,
>>
>> I agree that it is still possible to run JUnit tests from command line
>> even without having main() in the code. But I think it is easier to
>> run test by convenient way
>>
>>   $ java -cp junit.jar TestClass
>>
>> rather than in a more complex manner
>>
>>   $ java -cp junit.jar junit.textui.TestRunner TestClass
>>
>> Actually, I constantly forget the right spelling of the full class
>> name for TestRunner class and have to look into JUnit doc to specify
>> proper name for such a command line.
>>
>> Also, it would be inconvenient if
>> someone runs test from an IDE that does not support JUnit environment,
>> but launches test as a usual Java application.
>>
>> I don't insist on adding main() to each JUnit testcase, but I see no
>> reason for removing this functionality from those test where it
>> already exists.
>>     
>
> Whatever we do, main() should either be in all tests or none.  Having it
> in only a subset is *much* too confusing.
>
> I don't care if we have main() in testcases or not.  (I personally will
> never use it and don't find remembering[0] the junit test runner class.)
>   
+1 to keep a consistent style.
> Regards,
>  Mark.
>
> [0] I remember it by writing it in a shell script because I have a 
> terrible memory.

> Thanks.
> Ivan
>
> On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
>   
>>> Ivan, Stepan,
>>>
>>> I personally set +1 for removing main() method. Any script or command
>>> line can be trivially modified to launch JUnit tests without main()
>>> method: one should just add junit.textui.TestRunner class before a
>>> test class name.
>>>
>>> $ java -cp junit.jar junit.textui.TestRunner TestClass
>>>
>>> I'm writing this trivial thing here because during our work on class
>>> library test enabling it was FAQ N1 for all C/C++ developers.
>>>
>>> Note, any JUnit test won't work without junit.jar anyway. If you have
>>> junit.jar, you have a standard test runner, which is also quite
>>> lightweight.
>>>
>>> --
>>> Thank you,
>>> Alexei
>>>
>>> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
>>>       
>>>> -1 for removing main().
>>>>
>>>> I often run individual tests from command line or using scripts and
>>>> it's easier to launch them as a usual Java application. Also, this
>>>> facilitates creating separate bundle with test to attach to a bug
>>>> report or send to other people, who can just run it from command line
>>>> or use script with the all required options already specified, instead
>>>> of setting IDE for this test.
>>>>
>>>> Thanks.
>>>> Ivan
>>>>
>>>> On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
>>>>         
>>>>> There is a large amount of inconsistency across the tests and I'd like
>>>>> to lobby for cleaning them up as much as possible. I'm of the opinion
>>>>> that test code should be clean, simple and transparent. Here are some
>>>>> of the more noticeable items that I'd like to cleanup.
>>>>>
>>>>> * Empty setUp/teardown methods - There are a number of tests that
>>>>> override setUp and/or teardown methods, but are either empty or just
>>>>> call the super implementation.
>>>>>
>>>>> * Singleton suite methods - There are some tests that contain a static
>>>>> "suite" method that creates a TestSuite and adds one test (the test
>>>>> class it's declared in). Are there any practical uses for these
>>>>> methods? TestSuites are for grouping together tests to treat them as
>>>>> one unit. Since these suites are just one test, it doesn't seem to
>>>>> provide much value.
>>>>>
>>>>> * main method launching text runner - There are some tests that
>>>>> contain "main" methods which run the enclosing test via a JUnit text
>>>>> runner. Most IDEs have built-in support for JUnit and can launch any
>>>>> test arbitrarily and Ant can do the same thing. Does anyone launch
>>>>> tests via these methods?
>>>>>
>>>>> My proposal would be to clean up these inconsistencies by eliminating
>>>>> them, but what does everyone else think?
>>>>>
>>>>> -Nathan
>>>>>
>>>>>           
>
>
>
>   


-- 
Paulex Yang
China Software Development Lab
IBM



Re: [general] JUnit consistency, practices

Posted by Mark Hindess <ma...@googlemail.com>.
On 29 November 2006 at 20:34, "Ivan Popov" <iv...@gmail.com> wrote:
> Alexei,
> 
> I agree that it is still possible to run JUnit tests from command line
> even without having main() in the code. But I think it is easier to
> run test by convenient way
> 
>   $ java -cp junit.jar TestClass
> 
> rather than in a more complex manner
> 
>   $ java -cp junit.jar junit.textui.TestRunner TestClass
> 
> Actually, I constantly forget the right spelling of the full class
> name for TestRunner class and have to look into JUnit doc to specify
> proper name for such a command line.
>
> Also, it would be inconvenient if
> someone runs test from an IDE that does not support JUnit environment,
> but launches test as a usual Java application.
> 
> I don't insist on adding main() to each JUnit testcase, but I see no
> reason for removing this functionality from those test where it
> already exists.

Whatever we do, main() should either be in all tests or none.  Having it
in only a subset is *much* too confusing.

I don't care if we have main() in testcases or not.  (I personally will
never use it and don't find remembering[0] the junit test runner class.)

Regards,
 Mark.

[0] I remember it by writing it in a shell script because I have a 
terrible memory.

> Thanks.
> Ivan
> 
> On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
> > Ivan, Stepan,
> >
> > I personally set +1 for removing main() method. Any script or command
> > line can be trivially modified to launch JUnit tests without main()
> > method: one should just add junit.textui.TestRunner class before a
> > test class name.
> >
> > $ java -cp junit.jar junit.textui.TestRunner TestClass
> >
> > I'm writing this trivial thing here because during our work on class
> > library test enabling it was FAQ N1 for all C/C++ developers.
> >
> > Note, any JUnit test won't work without junit.jar anyway. If you have
> > junit.jar, you have a standard test runner, which is also quite
> > lightweight.
> >
> > --
> > Thank you,
> > Alexei
> >
> > On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> > > -1 for removing main().
> > >
> > > I often run individual tests from command line or using scripts and
> > > it's easier to launch them as a usual Java application. Also, this
> > > facilitates creating separate bundle with test to attach to a bug
> > > report or send to other people, who can just run it from command line
> > > or use script with the all required options already specified, instead
> > > of setting IDE for this test.
> > >
> > > Thanks.
> > > Ivan
> > >
> > > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> > > > There is a large amount of inconsistency across the tests and I'd like
> > > > to lobby for cleaning them up as much as possible. I'm of the opinion
> > > > that test code should be clean, simple and transparent. Here are some
> > > > of the more noticeable items that I'd like to cleanup.
> > > >
> > > > * Empty setUp/teardown methods - There are a number of tests that
> > > > override setUp and/or teardown methods, but are either empty or just
> > > > call the super implementation.
> > > >
> > > > * Singleton suite methods - There are some tests that contain a static
> > > > "suite" method that creates a TestSuite and adds one test (the test
> > > > class it's declared in). Are there any practical uses for these
> > > > methods? TestSuites are for grouping together tests to treat them as
> > > > one unit. Since these suites are just one test, it doesn't seem to
> > > > provide much value.
> > > >
> > > > * main method launching text runner - There are some tests that
> > > > contain "main" methods which run the enclosing test via a JUnit text
> > > > runner. Most IDEs have built-in support for JUnit and can launch any
> > > > test arbitrarily and Ant can do the same thing. Does anyone launch
> > > > tests via these methods?
> > > >
> > > > My proposal would be to clean up these inconsistencies by eliminating
> > > > them, but what does everyone else think?
> > > >
> > > > -Nathan
> > > >
> > >
> >
> 



Re: [general] JUnit consistency, practices

Posted by Alexei Fedotov <al...@gmail.com>.
This class name cannot fit into my mind either. I cut&paste this
mantra from different posts of Alexey Zakharov or use bash history.
:-)

On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> Alexei,
>
> I agree that it is still possible to run JUnit tests from command line
> even without having main() in the code. But I think it is easier to
> run test by convenient way
>
>  $ java -cp junit.jar TestClass
>
> rather than in a more complex manner
>
>  $ java -cp junit.jar junit.textui.TestRunner TestClass
>
> Actually, I constantly forget the right spelling of the full class
> name for TestRunner class and have to look into JUnit doc to specify
> proper name for such a command line. Also, it would be inconvenient if
> someone runs test from an IDE that does not support JUnit environment,
> but launches test as a usual Java application.
>
> I don't insist on adding main() to each JUnit testcase, but I see no
> reason for removing this functionality from those test where it
> already exists.
>
> Thanks.
> Ivan
>
> On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
> > Ivan, Stepan,
> >
> > I personally set +1 for removing main() method. Any script or command
> > line can be trivially modified to launch JUnit tests without main()
> > method: one should just add junit.textui.TestRunner class before a
> > test class name.
> >
> > $ java -cp junit.jar junit.textui.TestRunner TestClass
> >
> > I'm writing this trivial thing here because during our work on class
> > library test enabling it was FAQ N1 for all C/C++ developers.
> >
> > Note, any JUnit test won't work without junit.jar anyway. If you have
> > junit.jar, you have a standard test runner, which is also quite
> > lightweight.
> >
> > --
> > Thank you,
> > Alexei
> >
> > On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> > > -1 for removing main().
> > >
> > > I often run individual tests from command line or using scripts and
> > > it's easier to launch them as a usual Java application. Also, this
> > > facilitates creating separate bundle with test to attach to a bug
> > > report or send to other people, who can just run it from command line
> > > or use script with the all required options already specified, instead
> > > of setting IDE for this test.
> > >
> > > Thanks.
> > > Ivan
> > >
> > > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> > > > There is a large amount of inconsistency across the tests and I'd like
> > > > to lobby for cleaning them up as much as possible. I'm of the opinion
> > > > that test code should be clean, simple and transparent. Here are some
> > > > of the more noticeable items that I'd like to cleanup.
> > > >
> > > > * Empty setUp/teardown methods - There are a number of tests that
> > > > override setUp and/or teardown methods, but are either empty or just
> > > > call the super implementation.
> > > >
> > > > * Singleton suite methods - There are some tests that contain a static
> > > > "suite" method that creates a TestSuite and adds one test (the test
> > > > class it's declared in). Are there any practical uses for these
> > > > methods? TestSuites are for grouping together tests to treat them as
> > > > one unit. Since these suites are just one test, it doesn't seem to
> > > > provide much value.
> > > >
> > > > * main method launching text runner - There are some tests that
> > > > contain "main" methods which run the enclosing test via a JUnit text
> > > > runner. Most IDEs have built-in support for JUnit and can launch any
> > > > test arbitrarily and Ant can do the same thing. Does anyone launch
> > > > tests via these methods?
> > > >
> > > > My proposal would be to clean up these inconsistencies by eliminating
> > > > them, but what does everyone else think?
> > > >
> > > > -Nathan
> > > >
> > >
> >
>


-- 
Thank you,
Alexei

Re: [general] JUnit consistency, practices

Posted by Oliver Deakin <ol...@googlemail.com>.
I was thinking of putting in as much information as possible :)

So if there is a way to run a single test class using our current build 
system,
it should be in there. The manual method mentioned in this thread should
also be listed - give everyone as much info as possible.

Regards,
Oli

Alexei Zakharov wrote:
> +1 for having the doc. But personally I don't know the way how to run
> tests from the particular test class (not to speak of individual test
> methods) using the current build system. So I don't really know what
> exactly should be copy/pasted.  Or you was talking about by-hand test
> invocation cmd mentioned above?
>
> Thanks,
>
> 2006/12/5, Tony Wu <wu...@gmail.com>:
>> Agree! When I tried harmony on some applications, I found it is very
>> hard to run the test of application mainly because there is no
>> instruction for that at all. So I think it is also not very easy for
>> user who have interest to run tests of harmony. And a good instruction
>> may be good for having many user's help to run harmony tests on
>> various platforms.
>>
>> On 12/4/06, Oliver Deakin <ol...@googlemail.com> wrote:
>> > Perhaps some kind of "How To Run The Classlib Tests" section on
>> > the website would be useful? (Assuming there isn't already one with
>> > this information in) Then none of us would have to remember - it
>> > would be right there to copy/paste :)
>> >
>> > Regards,
>> > Oliver
>> >
>> >
>> > Ivan Popov wrote:
>> > > Alexei,
>> > >
>> > > I agree that it is still possible to run JUnit tests from command 
>> line
>> > > even without having main() in the code. But I think it is easier to
>> > > run test by convenient way
>> > >
>> > >  $ java -cp junit.jar TestClass
>> > >
>> > > rather than in a more complex manner
>> > >
>> > >  $ java -cp junit.jar junit.textui.TestRunner TestClass
>> > >
>> > > Actually, I constantly forget the right spelling of the full class
>> > > name for TestRunner class and have to look into JUnit doc to specify
>> > > proper name for such a command line. Also, it would be 
>> inconvenient if
>> > > someone runs test from an IDE that does not support JUnit 
>> environment,
>> > > but launches test as a usual Java application.
>> > >
>> > > I don't insist on adding main() to each JUnit testcase, but I see no
>> > > reason for removing this functionality from those test where it
>> > > already exists.
>> > >
>> > > Thanks.
>> > > Ivan
>> > >
>> > > On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
>> > >> Ivan, Stepan,
>> > >>
>> > >> I personally set +1 for removing main() method. Any script or 
>> command
>> > >> line can be trivially modified to launch JUnit tests without main()
>> > >> method: one should just add junit.textui.TestRunner class before a
>> > >> test class name.
>> > >>
>> > >> $ java -cp junit.jar junit.textui.TestRunner TestClass
>> > >>
>> > >> I'm writing this trivial thing here because during our work on 
>> class
>> > >> library test enabling it was FAQ N1 for all C/C++ developers.
>> > >>
>> > >> Note, any JUnit test won't work without junit.jar anyway. If you 
>> have
>> > >> junit.jar, you have a standard test runner, which is also quite
>> > >> lightweight.
>> > >>
>> > >> --
>> > >> Thank you,
>> > >> Alexei
>> > >>
>> > >> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
>> > >> > -1 for removing main().
>> > >> >
>> > >> > I often run individual tests from command line or using 
>> scripts and
>> > >> > it's easier to launch them as a usual Java application. Also, 
>> this
>> > >> > facilitates creating separate bundle with test to attach to a bug
>> > >> > report or send to other people, who can just run it from 
>> command line
>> > >> > or use script with the all required options already specified, 
>> instead
>> > >> > of setting IDE for this test.
>> > >> >
>> > >> > Thanks.
>> > >> > Ivan
>> > >> >
>> > >> > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
>> > >> > > There is a large amount of inconsistency across the tests 
>> and I'd
>> > >> like
>> > >> > > to lobby for cleaning them up as much as possible. I'm of the
>> > >> opinion
>> > >> > > that test code should be clean, simple and transparent. Here 
>> are
>> > >> some
>> > >> > > of the more noticeable items that I'd like to cleanup.
>> > >> > >
>> > >> > > * Empty setUp/teardown methods - There are a number of tests 
>> that
>> > >> > > override setUp and/or teardown methods, but are either empty 
>> or just
>> > >> > > call the super implementation.
>> > >> > >
>> > >> > > * Singleton suite methods - There are some tests that contain a
>> > >> static
>> > >> > > "suite" method that creates a TestSuite and adds one test 
>> (the test
>> > >> > > class it's declared in). Are there any practical uses for these
>> > >> > > methods? TestSuites are for grouping together tests to treat 
>> them as
>> > >> > > one unit. Since these suites are just one test, it doesn't 
>> seem to
>> > >> > > provide much value.
>> > >> > >
>> > >> > > * main method launching text runner - There are some tests that
>> > >> > > contain "main" methods which run the enclosing test via a 
>> JUnit text
>> > >> > > runner. Most IDEs have built-in support for JUnit and can 
>> launch any
>> > >> > > test arbitrarily and Ant can do the same thing. Does anyone 
>> launch
>> > >> > > tests via these methods?
>> > >> > >
>> > >> > > My proposal would be to clean up these inconsistencies by
>> > >> eliminating
>> > >> > > them, but what does everyone else think?
>> > >> > >
>> > >> > > -Nathan
>> > >> > >
>> > >> >
>> > >>
>> > >
>> >
>> > --
>> > Oliver Deakin
>> > IBM United Kingdom Limited
>> >
>> >
>>
>>
>> -- 
>> Tony Wu
>> China Software Development Lab, IBM
>>
>
>

-- 
Oliver Deakin
IBM United Kingdom Limited


Re: [general] JUnit consistency, practices

Posted by Alexei Zakharov <al...@gmail.com>.
+1 for having the doc. But personally I don't know the way how to run
tests from the particular test class (not to speak of individual test
methods) using the current build system. So I don't really know what
exactly should be copy/pasted.  Or you was talking about by-hand test
invocation cmd mentioned above?

Thanks,

2006/12/5, Tony Wu <wu...@gmail.com>:
> Agree! When I tried harmony on some applications, I found it is very
> hard to run the test of application mainly because there is no
> instruction for that at all. So I think it is also not very easy for
> user who have interest to run tests of harmony. And a good instruction
> may be good for having many user's help to run harmony tests on
> various platforms.
>
> On 12/4/06, Oliver Deakin <ol...@googlemail.com> wrote:
> > Perhaps some kind of "How To Run The Classlib Tests" section on
> > the website would be useful? (Assuming there isn't already one with
> > this information in) Then none of us would have to remember - it
> > would be right there to copy/paste :)
> >
> > Regards,
> > Oliver
> >
> >
> > Ivan Popov wrote:
> > > Alexei,
> > >
> > > I agree that it is still possible to run JUnit tests from command line
> > > even without having main() in the code. But I think it is easier to
> > > run test by convenient way
> > >
> > >  $ java -cp junit.jar TestClass
> > >
> > > rather than in a more complex manner
> > >
> > >  $ java -cp junit.jar junit.textui.TestRunner TestClass
> > >
> > > Actually, I constantly forget the right spelling of the full class
> > > name for TestRunner class and have to look into JUnit doc to specify
> > > proper name for such a command line. Also, it would be inconvenient if
> > > someone runs test from an IDE that does not support JUnit environment,
> > > but launches test as a usual Java application.
> > >
> > > I don't insist on adding main() to each JUnit testcase, but I see no
> > > reason for removing this functionality from those test where it
> > > already exists.
> > >
> > > Thanks.
> > > Ivan
> > >
> > > On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
> > >> Ivan, Stepan,
> > >>
> > >> I personally set +1 for removing main() method. Any script or command
> > >> line can be trivially modified to launch JUnit tests without main()
> > >> method: one should just add junit.textui.TestRunner class before a
> > >> test class name.
> > >>
> > >> $ java -cp junit.jar junit.textui.TestRunner TestClass
> > >>
> > >> I'm writing this trivial thing here because during our work on class
> > >> library test enabling it was FAQ N1 for all C/C++ developers.
> > >>
> > >> Note, any JUnit test won't work without junit.jar anyway. If you have
> > >> junit.jar, you have a standard test runner, which is also quite
> > >> lightweight.
> > >>
> > >> --
> > >> Thank you,
> > >> Alexei
> > >>
> > >> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> > >> > -1 for removing main().
> > >> >
> > >> > I often run individual tests from command line or using scripts and
> > >> > it's easier to launch them as a usual Java application. Also, this
> > >> > facilitates creating separate bundle with test to attach to a bug
> > >> > report or send to other people, who can just run it from command line
> > >> > or use script with the all required options already specified, instead
> > >> > of setting IDE for this test.
> > >> >
> > >> > Thanks.
> > >> > Ivan
> > >> >
> > >> > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> > >> > > There is a large amount of inconsistency across the tests and I'd
> > >> like
> > >> > > to lobby for cleaning them up as much as possible. I'm of the
> > >> opinion
> > >> > > that test code should be clean, simple and transparent. Here are
> > >> some
> > >> > > of the more noticeable items that I'd like to cleanup.
> > >> > >
> > >> > > * Empty setUp/teardown methods - There are a number of tests that
> > >> > > override setUp and/or teardown methods, but are either empty or just
> > >> > > call the super implementation.
> > >> > >
> > >> > > * Singleton suite methods - There are some tests that contain a
> > >> static
> > >> > > "suite" method that creates a TestSuite and adds one test (the test
> > >> > > class it's declared in). Are there any practical uses for these
> > >> > > methods? TestSuites are for grouping together tests to treat them as
> > >> > > one unit. Since these suites are just one test, it doesn't seem to
> > >> > > provide much value.
> > >> > >
> > >> > > * main method launching text runner - There are some tests that
> > >> > > contain "main" methods which run the enclosing test via a JUnit text
> > >> > > runner. Most IDEs have built-in support for JUnit and can launch any
> > >> > > test arbitrarily and Ant can do the same thing. Does anyone launch
> > >> > > tests via these methods?
> > >> > >
> > >> > > My proposal would be to clean up these inconsistencies by
> > >> eliminating
> > >> > > them, but what does everyone else think?
> > >> > >
> > >> > > -Nathan
> > >> > >
> > >> >
> > >>
> > >
> >
> > --
> > Oliver Deakin
> > IBM United Kingdom Limited
> >
> >
>
>
> --
> Tony Wu
> China Software Development Lab, IBM
>


-- 
Alexei Zakharov,
Intel Enterprise Solutions Software Division

Re: [general] JUnit consistency, practices

Posted by Tony Wu <wu...@gmail.com>.
Agree! When I tried harmony on some applications, I found it is very
hard to run the test of application mainly because there is no
instruction for that at all. So I think it is also not very easy for
user who have interest to run tests of harmony. And a good instruction
may be good for having many user's help to run harmony tests on
various platforms.

On 12/4/06, Oliver Deakin <ol...@googlemail.com> wrote:
> Perhaps some kind of "How To Run The Classlib Tests" section on
> the website would be useful? (Assuming there isn't already one with
> this information in) Then none of us would have to remember - it
> would be right there to copy/paste :)
>
> Regards,
> Oliver
>
>
> Ivan Popov wrote:
> > Alexei,
> >
> > I agree that it is still possible to run JUnit tests from command line
> > even without having main() in the code. But I think it is easier to
> > run test by convenient way
> >
> >  $ java -cp junit.jar TestClass
> >
> > rather than in a more complex manner
> >
> >  $ java -cp junit.jar junit.textui.TestRunner TestClass
> >
> > Actually, I constantly forget the right spelling of the full class
> > name for TestRunner class and have to look into JUnit doc to specify
> > proper name for such a command line. Also, it would be inconvenient if
> > someone runs test from an IDE that does not support JUnit environment,
> > but launches test as a usual Java application.
> >
> > I don't insist on adding main() to each JUnit testcase, but I see no
> > reason for removing this functionality from those test where it
> > already exists.
> >
> > Thanks.
> > Ivan
> >
> > On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
> >> Ivan, Stepan,
> >>
> >> I personally set +1 for removing main() method. Any script or command
> >> line can be trivially modified to launch JUnit tests without main()
> >> method: one should just add junit.textui.TestRunner class before a
> >> test class name.
> >>
> >> $ java -cp junit.jar junit.textui.TestRunner TestClass
> >>
> >> I'm writing this trivial thing here because during our work on class
> >> library test enabling it was FAQ N1 for all C/C++ developers.
> >>
> >> Note, any JUnit test won't work without junit.jar anyway. If you have
> >> junit.jar, you have a standard test runner, which is also quite
> >> lightweight.
> >>
> >> --
> >> Thank you,
> >> Alexei
> >>
> >> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> >> > -1 for removing main().
> >> >
> >> > I often run individual tests from command line or using scripts and
> >> > it's easier to launch them as a usual Java application. Also, this
> >> > facilitates creating separate bundle with test to attach to a bug
> >> > report or send to other people, who can just run it from command line
> >> > or use script with the all required options already specified, instead
> >> > of setting IDE for this test.
> >> >
> >> > Thanks.
> >> > Ivan
> >> >
> >> > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> >> > > There is a large amount of inconsistency across the tests and I'd
> >> like
> >> > > to lobby for cleaning them up as much as possible. I'm of the
> >> opinion
> >> > > that test code should be clean, simple and transparent. Here are
> >> some
> >> > > of the more noticeable items that I'd like to cleanup.
> >> > >
> >> > > * Empty setUp/teardown methods - There are a number of tests that
> >> > > override setUp and/or teardown methods, but are either empty or just
> >> > > call the super implementation.
> >> > >
> >> > > * Singleton suite methods - There are some tests that contain a
> >> static
> >> > > "suite" method that creates a TestSuite and adds one test (the test
> >> > > class it's declared in). Are there any practical uses for these
> >> > > methods? TestSuites are for grouping together tests to treat them as
> >> > > one unit. Since these suites are just one test, it doesn't seem to
> >> > > provide much value.
> >> > >
> >> > > * main method launching text runner - There are some tests that
> >> > > contain "main" methods which run the enclosing test via a JUnit text
> >> > > runner. Most IDEs have built-in support for JUnit and can launch any
> >> > > test arbitrarily and Ant can do the same thing. Does anyone launch
> >> > > tests via these methods?
> >> > >
> >> > > My proposal would be to clean up these inconsistencies by
> >> eliminating
> >> > > them, but what does everyone else think?
> >> > >
> >> > > -Nathan
> >> > >
> >> >
> >>
> >
>
> --
> Oliver Deakin
> IBM United Kingdom Limited
>
>


-- 
Tony Wu
China Software Development Lab, IBM

Re: [general] JUnit consistency, practices

Posted by Oliver Deakin <ol...@googlemail.com>.
Perhaps some kind of "How To Run The Classlib Tests" section on
the website would be useful? (Assuming there isn't already one with
this information in) Then none of us would have to remember - it
would be right there to copy/paste :)

Regards,
Oliver


Ivan Popov wrote:
> Alexei,
>
> I agree that it is still possible to run JUnit tests from command line
> even without having main() in the code. But I think it is easier to
> run test by convenient way
>
>  $ java -cp junit.jar TestClass
>
> rather than in a more complex manner
>
>  $ java -cp junit.jar junit.textui.TestRunner TestClass
>
> Actually, I constantly forget the right spelling of the full class
> name for TestRunner class and have to look into JUnit doc to specify
> proper name for such a command line. Also, it would be inconvenient if
> someone runs test from an IDE that does not support JUnit environment,
> but launches test as a usual Java application.
>
> I don't insist on adding main() to each JUnit testcase, but I see no
> reason for removing this functionality from those test where it
> already exists.
>
> Thanks.
> Ivan
>
> On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
>> Ivan, Stepan,
>>
>> I personally set +1 for removing main() method. Any script or command
>> line can be trivially modified to launch JUnit tests without main()
>> method: one should just add junit.textui.TestRunner class before a
>> test class name.
>>
>> $ java -cp junit.jar junit.textui.TestRunner TestClass
>>
>> I'm writing this trivial thing here because during our work on class
>> library test enabling it was FAQ N1 for all C/C++ developers.
>>
>> Note, any JUnit test won't work without junit.jar anyway. If you have
>> junit.jar, you have a standard test runner, which is also quite
>> lightweight.
>>
>> -- 
>> Thank you,
>> Alexei
>>
>> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
>> > -1 for removing main().
>> >
>> > I often run individual tests from command line or using scripts and
>> > it's easier to launch them as a usual Java application. Also, this
>> > facilitates creating separate bundle with test to attach to a bug
>> > report or send to other people, who can just run it from command line
>> > or use script with the all required options already specified, instead
>> > of setting IDE for this test.
>> >
>> > Thanks.
>> > Ivan
>> >
>> > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
>> > > There is a large amount of inconsistency across the tests and I'd 
>> like
>> > > to lobby for cleaning them up as much as possible. I'm of the 
>> opinion
>> > > that test code should be clean, simple and transparent. Here are 
>> some
>> > > of the more noticeable items that I'd like to cleanup.
>> > >
>> > > * Empty setUp/teardown methods - There are a number of tests that
>> > > override setUp and/or teardown methods, but are either empty or just
>> > > call the super implementation.
>> > >
>> > > * Singleton suite methods - There are some tests that contain a 
>> static
>> > > "suite" method that creates a TestSuite and adds one test (the test
>> > > class it's declared in). Are there any practical uses for these
>> > > methods? TestSuites are for grouping together tests to treat them as
>> > > one unit. Since these suites are just one test, it doesn't seem to
>> > > provide much value.
>> > >
>> > > * main method launching text runner - There are some tests that
>> > > contain "main" methods which run the enclosing test via a JUnit text
>> > > runner. Most IDEs have built-in support for JUnit and can launch any
>> > > test arbitrarily and Ant can do the same thing. Does anyone launch
>> > > tests via these methods?
>> > >
>> > > My proposal would be to clean up these inconsistencies by 
>> eliminating
>> > > them, but what does everyone else think?
>> > >
>> > > -Nathan
>> > >
>> >
>>
>

-- 
Oliver Deakin
IBM United Kingdom Limited


Re: [general] JUnit consistency, practices

Posted by Ivan Popov <iv...@gmail.com>.
Alexei,

I agree that it is still possible to run JUnit tests from command line
even without having main() in the code. But I think it is easier to
run test by convenient way

  $ java -cp junit.jar TestClass

rather than in a more complex manner

  $ java -cp junit.jar junit.textui.TestRunner TestClass

Actually, I constantly forget the right spelling of the full class
name for TestRunner class and have to look into JUnit doc to specify
proper name for such a command line. Also, it would be inconvenient if
someone runs test from an IDE that does not support JUnit environment,
but launches test as a usual Java application.

I don't insist on adding main() to each JUnit testcase, but I see no
reason for removing this functionality from those test where it
already exists.

Thanks.
Ivan

On 11/29/06, Alexei Fedotov <al...@gmail.com> wrote:
> Ivan, Stepan,
>
> I personally set +1 for removing main() method. Any script or command
> line can be trivially modified to launch JUnit tests without main()
> method: one should just add junit.textui.TestRunner class before a
> test class name.
>
> $ java -cp junit.jar junit.textui.TestRunner TestClass
>
> I'm writing this trivial thing here because during our work on class
> library test enabling it was FAQ N1 for all C/C++ developers.
>
> Note, any JUnit test won't work without junit.jar anyway. If you have
> junit.jar, you have a standard test runner, which is also quite
> lightweight.
>
> --
> Thank you,
> Alexei
>
> On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> > -1 for removing main().
> >
> > I often run individual tests from command line or using scripts and
> > it's easier to launch them as a usual Java application. Also, this
> > facilitates creating separate bundle with test to attach to a bug
> > report or send to other people, who can just run it from command line
> > or use script with the all required options already specified, instead
> > of setting IDE for this test.
> >
> > Thanks.
> > Ivan
> >
> > On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> > > There is a large amount of inconsistency across the tests and I'd like
> > > to lobby for cleaning them up as much as possible. I'm of the opinion
> > > that test code should be clean, simple and transparent. Here are some
> > > of the more noticeable items that I'd like to cleanup.
> > >
> > > * Empty setUp/teardown methods - There are a number of tests that
> > > override setUp and/or teardown methods, but are either empty or just
> > > call the super implementation.
> > >
> > > * Singleton suite methods - There are some tests that contain a static
> > > "suite" method that creates a TestSuite and adds one test (the test
> > > class it's declared in). Are there any practical uses for these
> > > methods? TestSuites are for grouping together tests to treat them as
> > > one unit. Since these suites are just one test, it doesn't seem to
> > > provide much value.
> > >
> > > * main method launching text runner - There are some tests that
> > > contain "main" methods which run the enclosing test via a JUnit text
> > > runner. Most IDEs have built-in support for JUnit and can launch any
> > > test arbitrarily and Ant can do the same thing. Does anyone launch
> > > tests via these methods?
> > >
> > > My proposal would be to clean up these inconsistencies by eliminating
> > > them, but what does everyone else think?
> > >
> > > -Nathan
> > >
> >
>

Re: [general] JUnit consistency, practices

Posted by Alexei Fedotov <al...@gmail.com>.
Ivan, Stepan,

I personally set +1 for removing main() method. Any script or command
line can be trivially modified to launch JUnit tests without main()
method: one should just add junit.textui.TestRunner class before a
test class name.

$ java -cp junit.jar junit.textui.TestRunner TestClass

I'm writing this trivial thing here because during our work on class
library test enabling it was FAQ N1 for all C/C++ developers.

Note, any JUnit test won't work without junit.jar anyway. If you have
junit.jar, you have a standard test runner, which is also quite
lightweight.

-- 
Thank you,
Alexei

On 11/29/06, Ivan Popov <iv...@gmail.com> wrote:
> -1 for removing main().
>
> I often run individual tests from command line or using scripts and
> it's easier to launch them as a usual Java application. Also, this
> facilitates creating separate bundle with test to attach to a bug
> report or send to other people, who can just run it from command line
> or use script with the all required options already specified, instead
> of setting IDE for this test.
>
> Thanks.
> Ivan
>
> On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> > There is a large amount of inconsistency across the tests and I'd like
> > to lobby for cleaning them up as much as possible. I'm of the opinion
> > that test code should be clean, simple and transparent. Here are some
> > of the more noticeable items that I'd like to cleanup.
> >
> > * Empty setUp/teardown methods - There are a number of tests that
> > override setUp and/or teardown methods, but are either empty or just
> > call the super implementation.
> >
> > * Singleton suite methods - There are some tests that contain a static
> > "suite" method that creates a TestSuite and adds one test (the test
> > class it's declared in). Are there any practical uses for these
> > methods? TestSuites are for grouping together tests to treat them as
> > one unit. Since these suites are just one test, it doesn't seem to
> > provide much value.
> >
> > * main method launching text runner - There are some tests that
> > contain "main" methods which run the enclosing test via a JUnit text
> > runner. Most IDEs have built-in support for JUnit and can launch any
> > test arbitrarily and Ant can do the same thing. Does anyone launch
> > tests via these methods?
> >
> > My proposal would be to clean up these inconsistencies by eliminating
> > them, but what does everyone else think?
> >
> > -Nathan
> >
>

Re: [general] JUnit consistency, practices

Posted by Ivan Popov <iv...@gmail.com>.
-1 for removing main().

I often run individual tests from command line or using scripts and
it's easier to launch them as a usual Java application. Also, this
facilitates creating separate bundle with test to attach to a bug
report or send to other people, who can just run it from command line
or use script with the all required options already specified, instead
of setting IDE for this test.

Thanks.
Ivan

On 11/29/06, Nathan Beyer <nb...@gmail.com> wrote:
> There is a large amount of inconsistency across the tests and I'd like
> to lobby for cleaning them up as much as possible. I'm of the opinion
> that test code should be clean, simple and transparent. Here are some
> of the more noticeable items that I'd like to cleanup.
>
> * Empty setUp/teardown methods - There are a number of tests that
> override setUp and/or teardown methods, but are either empty or just
> call the super implementation.
>
> * Singleton suite methods - There are some tests that contain a static
> "suite" method that creates a TestSuite and adds one test (the test
> class it's declared in). Are there any practical uses for these
> methods? TestSuites are for grouping together tests to treat them as
> one unit. Since these suites are just one test, it doesn't seem to
> provide much value.
>
> * main method launching text runner - There are some tests that
> contain "main" methods which run the enclosing test via a JUnit text
> runner. Most IDEs have built-in support for JUnit and can launch any
> test arbitrarily and Ant can do the same thing. Does anyone launch
> tests via these methods?
>
> My proposal would be to clean up these inconsistencies by eliminating
> them, but what does everyone else think?
>
> -Nathan
>