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...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Messages 23064 - 23093 of 24385   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#23064 From: "david_syer" <david_syer@...>
Date: Wed Nov 17, 2010 2:57 pm
Subject: Clarification on deprecation of runBefores and runAfters
david_syer
Send Email Send Email
 
In BlockJunit4ClassRunner there is a deprecation with no explicit alternative
for runBefores and runAfters (at least I didn't understand the comment, so if it
is explicit it is not very clear).  Can someone clarify what is going to happen
here?

Some third party libraries extend BlockJUnit4ClassRunner and override these
methods.  What are they supposed to do?  It seems quite reasonable to want to
modify this behaviour (e.g. to repeat a test method but only run the befores and
afters once, or to add behaviour after the befores but before the test method).

#23065 From: David Saff <david@...>
Date: Wed Nov 17, 2010 3:56 pm
Subject: Re: Clarification on deprecation of runBefores and runAfters
dsaff
Send Email Send Email
 
This deprecation was a mistake.  Expect a de-deprecation in 4.9.

    David Saff

On Wed, Nov 17, 2010 at 9:57 AM, david_syer <david_syer@...> wrote:
> In BlockJunit4ClassRunner there is a deprecation with no explicit alternative
for runBefores and runAfters (at least I didn't understand the comment, so if it
is explicit it is not very clear).  Can someone clarify what is going to happen
here?
>
> Some third party libraries extend BlockJUnit4ClassRunner and override these
methods.  What are they supposed to do?  It seems quite reasonable to want to
modify this behaviour (e.g. to repeat a test method but only run the befores and
afters once, or to add behaviour after the befores but before the test method).
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23066 From: "gaurangnshah" <gaurangnshah@...>
Date: Thu Nov 18, 2010 12:07 pm
Subject: how to read JUnit report programatically
gaurangnshah
Send Email Send Email
 
Hi all,

I want to send the mail to client after the test suit run. So is there any way i
can come to know how many test cases have passed and how many testcases have
failed programatically??

#23067 From: David Saff <david@...>
Date: Thu Nov 18, 2010 3:11 pm
Subject: Re: how to read JUnit report programatically
dsaff
Send Email Send Email
 
gaurangnshah,

The simplest solution may be to look at using ant to run and report on
your tests.

    David Saff

On Thu, Nov 18, 2010 at 7:07 AM, gaurangnshah <gaurangnshah@...> wrote:
> Hi all,
>
> I want to send the mail to client after the test suit run. So is there any way
i can come to know how many test cases have passed and how many testcases have
failed programatically??
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23068 From: "David" <davids@...>
Date: Fri Nov 19, 2010 1:47 am
Subject: Re: Running JUnit tests from a separate Java application
dljande
Send Email Send Email
 
Hi,

Fantastic advice!

I would also like to tell whether the methodA was actually executed i.e. does it
exist.

Thanks,
David

--- In junit@yahoogroups.com, David Saff <david@...> wrote:
>
> David,
>
> 1) You want new JUnitCore.run(Request.method(Try.class, "methodA"));
> 2) You can't both extend from TestCase and mark your tests with @Test.
>  Remove the extends TestCase, and more things will work.
>
> Good luck,
>
>    David
>
> On Mon, Nov 15, 2010 at 8:54 PM, David <davids@...> wrote:
> > In Eclipse I have a project with a package and all my source code is in the
one package.
> >
> > I would like to run JUnit test cases selectively from a separate Java
application where I run the code
> >        org.junit.runner.JUnitCore.main("example.Try.methodA");
> > in an attempt to run the unit test 'methodA' in my JUnit test module which
looks like this:
> >
> > package example;
> >
> > import org.junit.*;
> > import junit.framework.TestCase;
> >
> > public class Try extends TestCase
> > {
> >        public Try(String name) {
> >                super(name);
> >        }
> >
> >        @Before
> >        public void baseState() {
> >        }
> >
> >        @Test
> >        public void methodA() {
> >        }
> >
> > }
> >
> > I get the error message 'Could not find class: example.Try.methodA'
> >
> > If I run Try.java as a JUnit Test I get the error
> > junit.framework.AssertionFailedError: No tests found in example.Try
> >
> >
> > David
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>

#23069 From: David Saff <david@...>
Date: Fri Nov 19, 2010 2:07 pm
Subject: Re: Re: Running JUnit tests from a separate Java application
dsaff
Send Email Send Email
 
I think that if methodA does not exist, you will get an error message.
  Do you see different behavior?

    David

On Thu, Nov 18, 2010 at 8:47 PM, David <davids@...> wrote:
> Hi,
>
> Fantastic advice!
>
> I would also like to tell whether the methodA was actually executed i.e. does
it exist.
>
> Thanks,
> David
>
> --- In junit@yahoogroups.com, David Saff <david@...> wrote:
>>
>> David,
>>
>> 1) You want new JUnitCore.run(Request.method(Try.class, "methodA"));
>> 2) You can't both extend from TestCase and mark your tests with @Test.
>>  Remove the extends TestCase, and more things will work.
>>
>> Good luck,
>>
>>    David
>>
>> On Mon, Nov 15, 2010 at 8:54 PM, David <davids@...> wrote:
>> > In Eclipse I have a project with a package and all my source code is in the
one package.
>> >
>> > I would like to run JUnit test cases selectively from a separate Java
application where I run the code
>> >        org.junit.runner.JUnitCore.main("example.Try.methodA");
>> > in an attempt to run the unit test 'methodA' in my JUnit test module which
looks like this:
>> >
>> > package example;
>> >
>> > import org.junit.*;
>> > import junit.framework.TestCase;
>> >
>> > public class Try extends TestCase
>> > {
>> >        public Try(String name) {
>> >                super(name);
>> >        }
>> >
>> >        @Before
>> >        public void baseState() {
>> >        }
>> >
>> >        @Test
>> >        public void methodA() {
>> >        }
>> >
>> > }
>> >
>> > I get the error message 'Could not find class: example.Try.methodA'
>> >
>> > If I run Try.java as a JUnit Test I get the error
>> > junit.framework.AssertionFailedError: No tests found in example.Try
>> >
>> >
>> > David
>> >
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23070 From: InsolvenÄní rejstřík <zizka@...>
Date: Mon Nov 22, 2010 12:53 am
Subject: Re: JUnit diff Reports
pekarna2
Send Email Send Email
 
Hi, I'm working on something similar,
see
http://ondra.zizka.cz/stranky/programovani/java/apps/JUnitDiff-junit-test-result\
s-report-comparison.texy

HTH,
Ondra


Frédéric Camblor wrote:
>
> Hi folks !
>
> Recently, I used the <junitreport> ant task and noticed no "diff with the
> previous report" was available.
>
> I then made a diff xsl to apply, in order to merge 2 junit results  :)
> I provide it to the community, you can use it freely if you are
> interested.
>
> In the archive, you have :
> - A XSL StyleSheet (diff-report.xsl), allowing to "decorate" a junit test
> xml result, depending on a previous junit test xml result.
> - A XSL StyleSheet (junit-noframes.xsl) I updated, in order to use
> decorated
> fields made by previous stylesheet.
> - A build.xml, demonstrating how to make the diff report depending on 2
> junit test results (note: The saxon9.jar is required in order to execute
> ant
> tasks : you'll find it on http://saxon.sourceforge.net/  (I tested with
> 9-0-0-2j and it works))
> - 2 little junit test results (cur.xml and prev.xml), allowing to launch
> the
> ant task and generate the diff report.
>
> Don't hesitate to expose your advices in order to improve this process.
>
> Best regards,
> Frédéric Camblor
>
>
> [Non-text portions of this message have been removed]
>
>
>


-----
InsolvenÄní rejstřík: http://www.pohlidame.cz/
--
View this message in context:
http://old.nabble.com/JUnit-diff-Reports-tp14346264p30260695.html
Sent from the JUnit - User mailing list archive at Nabble.com.

#23071 From: "David" <davids@...>
Date: Wed Nov 24, 2010 10:53 pm
Subject: Re: Running JUnit tests from a separate Java application
dljande
Send Email Send Email
 
I had hoped so but with

Result run = (new org.junit.runner.JUnitCore()).run(Request.method(Try.class,
actionWord));
System.out.println("Test result: " + run.wasSuccessful() );

I get run.wasSuccessful() returning false when the method fails or it does not
exist.

--- In junit@yahoogroups.com, David Saff <david@...> wrote:
>
> I think that if methodA does not exist, you will get an error message.
>  Do you see different behavior?
>
>    David
>
> On Thu, Nov 18, 2010 at 8:47 PM, David <davids@...> wrote:
> > Hi,
> >
> > Fantastic advice!
> >
> > I would also like to tell whether the methodA was actually executed i.e.
does it exist.
> >
> > Thanks,
> > David
> >
> > --- In junit@yahoogroups.com, David Saff <david@> wrote:
> >>
> >> David,
> >>
> >> 1) You want new JUnitCore.run(Request.method(Try.class, "methodA"));
> >> 2) You can't both extend from TestCase and mark your tests with @Test.
> >>  Remove the extends TestCase, and more things will work.
> >>
> >> Good luck,
> >>
> >>    David
> >>
> >> On Mon, Nov 15, 2010 at 8:54 PM, David <davids@> wrote:
> >> > In Eclipse I have a project with a package and all my source code is in
the one package.
> >> >
> >> > I would like to run JUnit test cases selectively from a separate Java
application where I run the code
> >> >        org.junit.runner.JUnitCore.main("example.Try.methodA");
> >> > in an attempt to run the unit test 'methodA' in my JUnit test module
which looks like this:
> >> >
> >> > package example;
> >> >
> >> > import org.junit.*;
> >> > import junit.framework.TestCase;
> >> >
> >> > public class Try extends TestCase
> >> > {
> >> >        public Try(String name) {
> >> >                super(name);
> >> >        }
> >> >
> >> >        @Before
> >> >        public void baseState() {
> >> >        }
> >> >
> >> >        @Test
> >> >        public void methodA() {
> >> >        }
> >> >
> >> > }
> >> >
> >> > I get the error message 'Could not find class: example.Try.methodA'
> >> >
> >> > If I run Try.java as a JUnit Test I get the error
> >> > junit.framework.AssertionFailedError: No tests found in example.Try
> >> >
> >> >
> >> > David
> >> >
> >> >
> >> >
> >> >
> >> > ------------------------------------
> >> >
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>

#23072 From: "David" <davids@...>
Date: Thu Nov 25, 2010 6:39 am
Subject: Reporting results when running JUnit tests from Java application
dljande
Send Email Send Email
 
When I run a JUnit TC I am calling
   Result run = core.run(Request.method(Testing.class, testmethod));
from a standard Java application.
I understand that I can use a RunListener to do my reporting of test results
which I want to do using an XSL transform of my XML output.

I am unclear on how I define the testcase that I am running each time to the
RunListener.

Many methods of RunListener refer to the junit.framework.Test item but in my
situation how can I specify the Test item to pass to the RunListener?

David

#23073 From: Julien Martin <balteo@...>
Date: Thu Nov 25, 2010 6:16 pm
Subject: Unit testing a private method??
balteo
Send Email Send Email
 
Hello,
I have not used unit testing a lot but I'll have to do so in my next
position as a developer. I have always wondered how to test a method that is
private. From a java point of view it is impossible. So how do you
circumvent this problem and how do you make sure your private methods
perform correctly?
Any comment welcome.
J.


[Non-text portions of this message have been removed]

#23074 From: Michael Hill <mike.hill@...>
Date: Fri Nov 26, 2010 4:26 am
Subject: Re: Unit testing a private method??
uly562000
Send Email Send Email
 
This usually works:

http://www.google.com/search?client=gmail&rls=gm&q=testing%20a%20private%20metho\
d
<http://www.google.com/search?client=gmail&rls=gm&q=testing%20a%20private%20meth\
od>
Seeya,
Hill


On Thu, Nov 25, 2010 at 1:16 PM, Julien Martin <balteo@...> wrote:

>
>
> Hello,
> I have not used unit testing a lot but I'll have to do so in my next
> position as a developer. I have always wondered how to test a method that
> is
> private. From a java point of view it is impossible. So how do you
> circumvent this problem and how do you make sure your private methods
> perform correctly?
> Any comment welcome.
> J.
>
> [Non-text portions of this message have been removed]
>
>
>


[Non-text portions of this message have been removed]

#23075 From: "nervousxians" <shockofpoint6@...>
Date: Fri Nov 26, 2010 3:35 am
Subject: Latest preference for organzing test package
nervousxians
Send Email Send Email
 
Hi guys,
I did search the group for an answer to my question, but could not find any
clear opinions. The JUnit FAQ also has a preference on organization but that has
not been updated since 2006. Also, if some people had adopted a particular
method, have you had any regrets and wished you had adopted the another method?

My question:What is a preferable method to place our JUnit tests.

Method A
----------
MyPackage
    src
       com
          mycompany
             MyClass.java

    test
       com
          mycompany...etc
             MyClassTest.java

Method B
-----------
MyPackage
    src
       com
          mycompany...etc
             MyClass.java

MyPackageTest
    src
       com
          mycompany...etc
             MyClassTest.java

#23076 From: Nicolas Dermine <nicolas.dermine@...>
Date: Fri Nov 26, 2010 3:29 am
Subject: Re: Unit testing a private method??
nicolas.dermine
Send Email Send Email
 
Hi Julien,

try googling 'testing private methods', you'll find lots of people who will
say that it's bad practice to want to do that (even if it's possible).

you'll likely test those methods through public methods that use them.

or if you feel they really need to be unit tested, then you may consider
making them public, maybe in a new class.

happy unit testing!
nico





On Thu, Nov 25, 2010 at 7:16 PM, Julien Martin <balteo@...> wrote:

>
>
> Hello,
> I have not used unit testing a lot but I'll have to do so in my next
> position as a developer. I have always wondered how to test a method that
> is
> private. From a java point of view it is impossible. So how do you
> circumvent this problem and how do you make sure your private methods
> perform correctly?
> Any comment welcome.
> J.
>
> [Non-text portions of this message have been removed]
>
>
>


[Non-text portions of this message have been removed]

#23077 From: "Amal Elaine" <amalelaine@...>
Date: Fri Nov 26, 2010 2:59 am
Subject: Re: Unit testing a private method??
amalcamel
Send Email Send Email
 
oops, I meant to say we make the private methods "protected".... sorry about
that.


   ----- Original Message -----
   From: Julien Martin
   To: junit@yahoogroups.com
   Sent: Thursday, November 25, 2010 1:16 PM
   Subject: [junit] Unit testing a private method??



   Hello,
   I have not used unit testing a lot but I'll have to do so in my next
   position as a developer. I have always wondered how to test a method that is
   private. From a java point of view it is impossible. So how do you
   circumvent this problem and how do you make sure your private methods
   perform correctly?
   Any comment welcome.
   J.

   [Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]

#23078 From: "Amal Elaine" <amalelaine@...>
Date: Fri Nov 26, 2010 2:59 am
Subject: Re: Unit testing a private method??
amalcamel
Send Email Send Email
 
We have our tests in the same package as the code (under a folder called
"test"), and then make the private methods public.


   ----- Original Message -----
   From: Julien Martin
   To: junit@yahoogroups.com
   Sent: Thursday, November 25, 2010 1:16 PM
   Subject: [junit] Unit testing a private method??



   Hello,
   I have not used unit testing a lot but I'll have to do so in my next
   position as a developer. I have always wondered how to test a method that is
   private. From a java point of view it is impossible. So how do you
   circumvent this problem and how do you make sure your private methods
   perform correctly?
   Any comment welcome.
   J.

   [Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]

#23079 From: Karl Auer <kauer@...>
Date: Fri Nov 26, 2010 2:37 am
Subject: Re: Unit testing a private method??
kristoferamp...
Send Email Send Email
 
On Thu, 2010-11-25 at 19:16 +0100, Julien Martin wrote:
> Hello,
> I have not used unit testing a lot but I'll have to do so in my next
> position as a developer. I have always wondered how to test a method that is
> private. From a java point of view it is impossible. So how do you
> circumvent this problem and how do you make sure your private methods
> perform correctly?
> Any comment welcome.

Google for "junit test private methods"

Some links that I think are succinct and useful are:

    http://www.artima.com/suiterunner/private.html

    http://onjava.com/pub/a/onjava/2003/11/12/reflection.html

At very least they are a good starting point.

Regards, K.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer@...)                   +61-2-64957160 (h)
http://www.biplane.com.au/kauer/                   +61-428-957160 (mob)

GPG fingerprint: B386 7819 B227 2961 8301 C5A9 2EBC 754B CD97 0156
Old fingerprint: 07F3 1DF9 9D45 8BCD 7DD5 00CE 4A44 6A03 F43A 7DEF


[Non-text portions of this message have been removed]

#23080 From: David Saff <david@...>
Date: Fri Nov 26, 2010 12:28 pm
Subject: Re: Latest preference for organzing test package
dsaff
Send Email Send Email
 
I think it depends on your development environment.  Maven, for
example, has a very strong preference for a certain organization.  It
looks like you might be organizing things in Eclipse--is that true?

    David

On Thu, Nov 25, 2010 at 10:35 PM, nervousxians
<shockofpoint6@...> wrote:
> Hi guys,
> I did search the group for an answer to my question, but could not find any
clear opinions. The JUnit FAQ also has a preference on organization but that has
not been updated since 2006. Also, if some people had adopted a particular
method, have you had any regrets and wished you had adopted the another method?
>
> My question:What is a preferable method to place our JUnit tests.
>
> Method A
> ----------
> MyPackage
>   src
>      com
>         mycompany
>            MyClass.java
>
>   test
>      com
>         mycompany...etc
>            MyClassTest.java
>
> Method B
> -----------
> MyPackage
>   src
>      com
>         mycompany...etc
>            MyClass.java
>
> MyPackageTest
>   src
>      com
>         mycompany...etc
>            MyClassTest.java
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23081 From: David Saff <david@...>
Date: Fri Nov 26, 2010 12:33 pm
Subject: Re: Reporting results when running JUnit tests from Java application
dsaff
Send Email Send Email
 
David,

In JUnit 4, you use RunListeners, by passing them to
JUnitCore.addListener.  Does that help?

    David

On Thu, Nov 25, 2010 at 1:39 AM, David <davids@...> wrote:
> When I run a JUnit TC I am calling
>  Result run = core.run(Request.method(Testing.class, testmethod));
> from a standard Java application.
> I understand that I can use a RunListener to do my reporting of test results
which I want to do using an XSL transform of my XML output.
>
> I am unclear on how I define the testcase that I am running each time to the
RunListener.
>
> Many methods of RunListener refer to the junit.framework.Test item but in my
situation how can I specify the Test item to pass to the RunListener?
>
> David
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23082 From: David Saff <david@...>
Date: Fri Nov 26, 2010 12:34 pm
Subject: Re: Re: Running JUnit tests from a separate Java application
dsaff
Send Email Send Email
 
That's the behavior I expect.  What were you expecting to see?

    David Saff

On Wed, Nov 24, 2010 at 5:53 PM, David <davids@...> wrote:
> I had hoped so but with
>
> Result run = (new org.junit.runner.JUnitCore()).run(Request.method(Try.class,
actionWord));
> System.out.println("Test result: " + run.wasSuccessful() );
>
> I get run.wasSuccessful() returning false when the method fails or it does not
exist.
>
> --- In junit@yahoogroups.com, David Saff <david@...> wrote:
>>
>> I think that if methodA does not exist, you will get an error message.
>>  Do you see different behavior?
>>
>>    David
>>
>> On Thu, Nov 18, 2010 at 8:47 PM, David <davids@...> wrote:
>> > Hi,
>> >
>> > Fantastic advice!
>> >
>> > I would also like to tell whether the methodA was actually executed i.e.
does it exist.
>> >
>> > Thanks,
>> > David
>> >
>> > --- In junit@yahoogroups.com, David Saff <david@> wrote:
>> >>
>> >> David,
>> >>
>> >> 1) You want new JUnitCore.run(Request.method(Try.class, "methodA"));
>> >> 2) You can't both extend from TestCase and mark your tests with @Test.
>> >>  Remove the extends TestCase, and more things will work.
>> >>
>> >> Good luck,
>> >>
>> >>    David
>> >>
>> >> On Mon, Nov 15, 2010 at 8:54 PM, David <davids@> wrote:
>> >> > In Eclipse I have a project with a package and all my source code is in
the one package.
>> >> >
>> >> > I would like to run JUnit test cases selectively from a separate Java
application where I run the code
>> >> >        org.junit.runner.JUnitCore.main("example.Try.methodA");
>> >> > in an attempt to run the unit test 'methodA' in my JUnit test module
which looks like this:
>> >> >
>> >> > package example;
>> >> >
>> >> > import org.junit.*;
>> >> > import junit.framework.TestCase;
>> >> >
>> >> > public class Try extends TestCase
>> >> > {
>> >> >        public Try(String name) {
>> >> >                super(name);
>> >> >        }
>> >> >
>> >> >        @Before
>> >> >        public void baseState() {
>> >> >        }
>> >> >
>> >> >        @Test
>> >> >        public void methodA() {
>> >> >        }
>> >> >
>> >> > }
>> >> >
>> >> > I get the error message 'Could not find class: example.Try.methodA'
>> >> >
>> >> > If I run Try.java as a JUnit Test I get the error
>> >> > junit.framework.AssertionFailedError: No tests found in example.Try
>> >> >
>> >> >
>> >> > David
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------
>> >> >
>> >> > Yahoo! Groups Links
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23083 From: Kristian Rosenvold <kristian@...>
Date: Fri Nov 26, 2010 3:12 pm
Subject: Re: Latest preference for organzing test package
krosenvold
Send Email Send Email
 
The maven directory structure is by far
fr., 26.11.2010 kl. 07.28 -0500, skrev David Saff:
>
> I think it depends on your development environment. Maven, for
> example, has a very strong preference for a certain organization. It
> looks like you might be organizing things in Eclipse--is that true?
>
> David
>
> On Thu, Nov 25, 2010 at 10:35 PM, nervousxians
> <shockofpoint6@...> wrote:
> > Hi guys,
> > I did search the group for an answer to my question, but could not
> find any clear opinions. The JUnit FAQ also has a preference on
> organization but that has not been updated since 2006. Also, if some
> people had adopted a particular method, have you had any regrets and
> wished you had adopted the another method?
> >
> > My question:What is a preferable method to place our JUnit tests.
> >
> > Method A
> > ----------
> > MyPackage
> >   src
> >      com
> >         mycompany
> >            MyClass.java
> >
> >   test
> >      com
> >         mycompany...etc
> >            MyClassTest.java
> >
> > Method B
> > -----------
> > MyPackage
> >   src
> >      com
> >         mycompany...etc
> >            MyClass.java
> >
> > MyPackageTest
> >   src
> >      com
> >         mycompany...etc
> >            MyClassTest.java
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
>
>

#23084 From: Kristian Rosenvold <kristian@...>
Date: Fri Nov 26, 2010 3:19 pm
Subject: Re: Latest preference for organzing test package
krosenvold
Send Email Send Email
 
The maven directory structure is by far the most popular "standard"
arrangement, and can be seen at
http://maven.apache.org/guides/introduction/introduction-to-the-standard-directo\
ry-layout.html

This structure is used by a lot of non-maven projects too, simply
because following a well known convention is better than making your
own.

An interesting side-effect of the maven structure is that the unit test
resides in the same package as the class being tested. This permits the
use of package-level protection for exposing "non-public" information
to the test. I know this is generally frowned upon, but sometimes nice
anyway. Personally I find the semantics of using "protected" so much
more convoluted (that keyword communicates so many other things), so I
find package level protection as nice alternative without all the
feelings that come with "protected".

Kristian


fr., 26.11.2010 kl. 16.12 +0100, skrev Kristian Rosenvold:
> The maven directory structure is by far
> fr., 26.11.2010 kl. 07.28 -0500, skrev David Saff:
> >
> > I think it depends on your development environment. Maven, for
> > example, has a very strong preference for a certain organization. It
> > looks like you might be organizing things in Eclipse--is that true?
> >
> > David
> >
> > On Thu, Nov 25, 2010 at 10:35 PM, nervousxians
> > <shockofpoint6@...> wrote:
> > > Hi guys,
> > > I did search the group for an answer to my question, but could not
> > find any clear opinions. The JUnit FAQ also has a preference on
> > organization but that has not been updated since 2006. Also, if some
> > people had adopted a particular method, have you had any regrets and
> > wished you had adopted the another method?
> > >
> > > My question:What is a preferable method to place our JUnit tests.
> > >
> > > Method A
> > > ----------
> > > MyPackage
> > >   src
> > >      com
> > >         mycompany
> > >            MyClass.java
> > >
> > >   test
> > >      com
> > >         mycompany...etc
> > >            MyClassTest.java
> > >
> > > Method B
> > > -----------
> > > MyPackage
> > >   src
> > >      com
> > >         mycompany...etc
> > >            MyClass.java
> > >
> > > MyPackageTest
> > >   src
> > >      com
> > >         mycompany...etc
> > >            MyClassTest.java
> > >
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>

#23085 From: "nervousxians" <shockofpoint6@...>
Date: Fri Nov 26, 2010 5:15 pm
Subject: Re: Latest preference for organzing test package
nervousxians
Send Email Send Email
 
David,
Yes, we are doing it through eclipse.

-Nelson

--- In junit@yahoogroups.com, David Saff <david@...> wrote:
>
> I think it depends on your development environment.  Maven, for
> example, has a very strong preference for a certain organization.  It
> looks like you might be organizing things in Eclipse--is that true?
>
>    David
>
> On Thu, Nov 25, 2010 at 10:35 PM, nervousxians
> <shockofpoint6@...> wrote:
> > Hi guys,
> > I did search the group for an answer to my question, but could not find any
clear opinions. The JUnit FAQ also has a preference on organization but that has
not been updated since 2006. Also, if some people had adopted a particular
method, have you had any regrets and wished you had adopted the another method?
> >
> > My question:What is a preferable method to place our JUnit tests.
> >
> > Method A
> > ----------
> > MyPackage
> >   src
> >      com
> >         mycompany
> >            MyClass.java
> >
> >   test
> >      com
> >         mycompany...etc
> >            MyClassTest.java
> >
> > Method B
> > -----------
> > MyPackage
> >   src
> >      com
> >         mycompany...etc
> >            MyClass.java
> >
> > MyPackageTest
> >   src
> >      com
> >         mycompany...etc
> >            MyClassTest.java
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>

#23086 From: Rafael <rafael.naufal@...>
Date: Fri Nov 26, 2010 4:12 pm
Subject: Re: Unit testing a private method??
rafael_naufal
Send Email Send Email
 
Private methods are "helper" methods for other methods. If you want to test
a private method, you should make it at least package private.

On Fri, Nov 26, 2010 at 00:37, Karl Auer <kauer@...> wrote:

>
>
> On Thu, 2010-11-25 at 19:16 +0100, Julien Martin wrote:
> > Hello,
> > I have not used unit testing a lot but I'll have to do so in my next
> > position as a developer. I have always wondered how to test a method that
> is
> > private. From a java point of view it is impossible. So how do you
> > circumvent this problem and how do you make sure your private methods
> > perform correctly?
> > Any comment welcome.
>
> Google for "junit test private methods"
>
> Some links that I think are succinct and useful are:
>
> http://www.artima.com/suiterunner/private.html
>
> http://onjava.com/pub/a/onjava/2003/11/12/reflection.html
>
> At very least they are a good starting point.
>
> Regards, K.
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Karl Auer (kauer@... <kauer%40biplane.com.au>) +61-2-64957160
> (h)
> http://www.biplane.com.au/kauer/ +61-428-957160 (mob)
>
> GPG fingerprint: B386 7819 B227 2961 8301 C5A9 2EBC 754B CD97 0156
> Old fingerprint: 07F3 1DF9 9D45 8BCD 7DD5 00CE 4A44 6A03 F43A 7DEF
>
>
> [Non-text portions of this message have been removed]
>
>
>



--
------------------------------------------------------------------------
Rafael Naufal
"A great pleasure in life is doing what people say you cannot do" -Walter
Gagehot
http://rafaelnaufal.com
Twitter: http://twitter.com/rnaufal
------------------------------------------------------------------------


[Non-text portions of this message have been removed]

#23087 From: "David" <davids@...>
Date: Sun Nov 28, 2010 11:01 pm
Subject: Re: Reporting results when running JUnit tests from Java application
dljande
Send Email Send Email
 
Many methods of RunListener refer to a junit.framework.Test item. In my
situation thanks to your advice I am able to call my testcases from a separate
Java application. I had to remove the 'extend TestCase' statement from my class
definition to achieve that. As a result I cannot access/specify a Test item to
pass to my RunListener.
A Test item could have provided a lot of information that I would like to
include in my results reporting.

David

--- In junit@yahoogroups.com, David Saff <david@...> wrote:
>
> David,
>
> In JUnit 4, you use RunListeners, by passing them to
> JUnitCore.addListener.  Does that help?
>
>    David
>
> On Thu, Nov 25, 2010 at 1:39 AM, David <davids@...> wrote:
> > When I run a JUnit TC I am calling
> >  Result run = core.run(Request.method(Testing.class, testmethod));
> > from a standard Java application.
> > I understand that I can use a RunListener to do my reporting of test results
which I want to do using an XSL transform of my XML output.
> >
> > I am unclear on how I define the testcase that I am running each time to the
RunListener.
> >
> > Many methods of RunListener refer to the junit.framework.Test item but in my
situation how can I specify the Test item to pass to the RunListener?
> >
> > David
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>

#23088 From: "David" <davids@...>
Date: Sun Nov 28, 2010 10:51 pm
Subject: Re: Running JUnit tests from a separate Java application
dljande
Send Email Send Email
 
I had hoped I could differentiate between a failed testcase and a failure
because the testcase does not exist.

David

--- In junit@yahoogroups.com, David Saff <david@...> wrote:
>
> That's the behavior I expect.  What were you expecting to see?
>
>    David Saff
>
> On Wed, Nov 24, 2010 at 5:53 PM, David <davids@...> wrote:
> > I had hoped so but with
> >
> > Result run = (new
org.junit.runner.JUnitCore()).run(Request.method(Try.class, actionWord));
> > System.out.println("Test result: " + run.wasSuccessful() );
> >
> > I get run.wasSuccessful() returning false when the method fails or it does
not exist.
> >
> > --- In junit@yahoogroups.com, David Saff <david@> wrote:
> >>
> >> I think that if methodA does not exist, you will get an error message.
> >>  Do you see different behavior?
> >>
> >>    David
> >>
> >> On Thu, Nov 18, 2010 at 8:47 PM, David <davids@> wrote:
> >> > Hi,
> >> >
> >> > Fantastic advice!
> >> >
> >> > I would also like to tell whether the methodA was actually executed i.e.
does it exist.
> >> >
> >> > Thanks,
> >> > David
> >> >
> >> > --- In junit@yahoogroups.com, David Saff <david@> wrote:
> >> >>
> >> >> David,
> >> >>
> >> >> 1) You want new JUnitCore.run(Request.method(Try.class, "methodA"));
> >> >> 2) You can't both extend from TestCase and mark your tests with @Test.
> >> >>  Remove the extends TestCase, and more things will work.
> >> >>
> >> >> Good luck,
> >> >>
> >> >>    David
> >> >>
> >> >> On Mon, Nov 15, 2010 at 8:54 PM, David <davids@> wrote:
> >> >> > In Eclipse I have a project with a package and all my source code is
in the one package.
> >> >> >
> >> >> > I would like to run JUnit test cases selectively from a separate Java
application where I run the code
> >> >> >        org.junit.runner.JUnitCore.main("example.Try.methodA");
> >> >> > in an attempt to run the unit test 'methodA' in my JUnit test module
which looks like this:
> >> >> >
> >> >> > package example;
> >> >> >
> >> >> > import org.junit.*;
> >> >> > import junit.framework.TestCase;
> >> >> >
> >> >> > public class Try extends TestCase
> >> >> > {
> >> >> >        public Try(String name) {
> >> >> >                super(name);
> >> >> >        }
> >> >> >
> >> >> >        @Before
> >> >> >        public void baseState() {
> >> >> >        }
> >> >> >
> >> >> >        @Test
> >> >> >        public void methodA() {
> >> >> >        }
> >> >> >
> >> >> > }
> >> >> >
> >> >> > I get the error message 'Could not find class: example.Try.methodA'
> >> >> >
> >> >> > If I run Try.java as a JUnit Test I get the error
> >> >> > junit.framework.AssertionFailedError: No tests found in example.Try
> >> >> >
> >> >> >
> >> >> > David
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > ------------------------------------
> >> >> >
> >> >> > Yahoo! Groups Links
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >
> >> >
> >> >
> >> >
> >> > ------------------------------------
> >> >
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>

#23089 From: David Saff <david@...>
Date: Mon Nov 29, 2010 1:45 pm
Subject: Re: Re: Running JUnit tests from a separate Java application
dsaff
Send Email Send Email
 
If the test case doesn't exist, I think the failure exception should
be a NoTestsRemainException.  Can you check for that?

    David Saff

On Sun, Nov 28, 2010 at 5:51 PM, David <davids@...> wrote:
> I had hoped I could differentiate between a failed testcase and a failure
because the testcase does not exist.
>
> David
>
> --- In junit@yahoogroups.com, David Saff <david@...> wrote:
>>
>> That's the behavior I expect.  What were you expecting to see?
>>
>>    David Saff
>>
>> On Wed, Nov 24, 2010 at 5:53 PM, David <davids@...> wrote:
>> > I had hoped so but with
>> >
>> > Result run = (new
org.junit.runner.JUnitCore()).run(Request.method(Try.class, actionWord));
>> > System.out.println("Test result: " + run.wasSuccessful() );
>> >
>> > I get run.wasSuccessful() returning false when the method fails or it does
not exist.
>> >
>> > --- In junit@yahoogroups.com, David Saff <david@> wrote:
>> >>
>> >> I think that if methodA does not exist, you will get an error message.
>> >>  Do you see different behavior?
>> >>
>> >>    David
>> >>
>> >> On Thu, Nov 18, 2010 at 8:47 PM, David <davids@> wrote:
>> >> > Hi,
>> >> >
>> >> > Fantastic advice!
>> >> >
>> >> > I would also like to tell whether the methodA was actually executed i.e.
does it exist.
>> >> >
>> >> > Thanks,
>> >> > David
>> >> >
>> >> > --- In junit@yahoogroups.com, David Saff <david@> wrote:
>> >> >>
>> >> >> David,
>> >> >>
>> >> >> 1) You want new JUnitCore.run(Request.method(Try.class, "methodA"));
>> >> >> 2) You can't both extend from TestCase and mark your tests with @Test.
>> >> >>  Remove the extends TestCase, and more things will work.
>> >> >>
>> >> >> Good luck,
>> >> >>
>> >> >>    David
>> >> >>
>> >> >> On Mon, Nov 15, 2010 at 8:54 PM, David <davids@> wrote:
>> >> >> > In Eclipse I have a project with a package and all my source code is
in the one package.
>> >> >> >
>> >> >> > I would like to run JUnit test cases selectively from a separate Java
application where I run the code
>> >> >> >        org.junit.runner.JUnitCore.main("example.Try.methodA");
>> >> >> > in an attempt to run the unit test 'methodA' in my JUnit test module
which looks like this:
>> >> >> >
>> >> >> > package example;
>> >> >> >
>> >> >> > import org.junit.*;
>> >> >> > import junit.framework.TestCase;
>> >> >> >
>> >> >> > public class Try extends TestCase
>> >> >> > {
>> >> >> >        public Try(String name) {
>> >> >> >                super(name);
>> >> >> >        }
>> >> >> >
>> >> >> >        @Before
>> >> >> >        public void baseState() {
>> >> >> >        }
>> >> >> >
>> >> >> >        @Test
>> >> >> >        public void methodA() {
>> >> >> >        }
>> >> >> >
>> >> >> > }
>> >> >> >
>> >> >> > I get the error message 'Could not find class: example.Try.methodA'
>> >> >> >
>> >> >> > If I run Try.java as a JUnit Test I get the error
>> >> >> > junit.framework.AssertionFailedError: No tests found in example.Try
>> >> >> >
>> >> >> >
>> >> >> > David
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > ------------------------------------
>> >> >> >
>> >> >> > Yahoo! Groups Links
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------
>> >> >
>> >> > Yahoo! Groups Links
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23090 From: David Saff <david@...>
Date: Mon Nov 29, 2010 1:47 pm
Subject: Re: Re: Reporting results when running JUnit tests from Java application
dsaff
Send Email Send Email
 
David,

I think we're hung up on the difference between:

1) junit.framework.TestListener.  This refers to Test instances, and
you shouldn't be using it.
2) org.junit.runner.notification.RunListener.  This refers to
Descriptions, and you should be using it.

Does this help?

    David Saff

On Sun, Nov 28, 2010 at 6:01 PM, David <davids@...> wrote:
> Many methods of RunListener refer to a junit.framework.Test item. In my
situation thanks to your advice I am able to call my testcases from a separate
Java application. I had to remove the 'extend TestCase' statement from my class
definition to achieve that. As a result I cannot access/specify a Test item to
pass to my RunListener.
> A Test item could have provided a lot of information that I would like to
include in my results reporting.
>
> David
>
> --- In junit@yahoogroups.com, David Saff <david@...> wrote:
>>
>> David,
>>
>> In JUnit 4, you use RunListeners, by passing them to
>> JUnitCore.addListener.  Does that help?
>>
>>    David
>>
>> On Thu, Nov 25, 2010 at 1:39 AM, David <davids@...> wrote:
>> > When I run a JUnit TC I am calling
>> >  Result run = core.run(Request.method(Testing.class, testmethod));
>> > from a standard Java application.
>> > I understand that I can use a RunListener to do my reporting of test
results which I want to do using an XSL transform of my XML output.
>> >
>> > I am unclear on how I define the testcase that I am running each time to
the RunListener.
>> >
>> > Many methods of RunListener refer to the junit.framework.Test item but in
my situation how can I specify the Test item to pass to the RunListener?
>> >
>> > David
>> >
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23091 From: "xdzgor" <pk@...>
Date: Tue Nov 30, 2010 9:03 pm
Subject: execute all tests in a jar
xdzgor
Send Email Send Email
 
Hi

I have a couple of questions:

(1) To run JUnit tests from the command-prompt, I can use JUnitCore. I have to
specify each test class I wish to run. Is it possible to specify a jar file,
which JUnitCore will inspect for all available test classes, and execute them?

(2) What does the output "EE.EE.EE.EE" etc, from JUnitCore mean?

Thanks,
Peter

#23092 From: David Saff <david@...>
Date: Tue Nov 30, 2010 9:58 pm
Subject: Re: execute all tests in a jar
dsaff
Send Email Send Email
 
On Tue, Nov 30, 2010 at 4:03 PM, xdzgor <pk@...> wrote:
> Hi
>
> I have a couple of questions:
>
> (1) To run JUnit tests from the command-prompt, I can use JUnitCore. I have to
specify each test class I wish to run. Is it possible to specify a jar file,
which JUnitCore will inspect for all available test classes, and execute them?

Not with core JUnit, but you should look at cpsuite and
https://github.com/dhemery/runtime-suite

> (2) What does the output "EE.EE.EE.EE" etc, from JUnitCore mean?

. = a test has started
E = a test has failed.

    David Saff

>
> Thanks,
> Peter
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23093 From: Lothar Kimmeringer <maillists_job@...>
Date: Wed Dec 1, 2010 7:39 am
Subject: Re: execute all tests in a jar
kimmerin_job
Send Email Send Email
 
Am 30.11.2010 22:03, schrieb xdzgor:
>
>
> (1) To run JUnit tests from the command-prompt, I can use JUnitCore.
> I have to specify each test class I wish to run. Is it possible
> to specify a jar file, which JUnitCore will inspect for all available
> test classes, and execute them?

I don't know, but you might try out Ant where there is a junit-Task:
     <target name="junit" depends="preparetests,buildjar" description="Tests all
junit-tests that can be found">
         <junit maxmemory="1024m" jvm="${junit.jvm.cmd}" printsummary="true"
fork="yes" dir="${basedir}">
           <jvmarg value="-Djava.library.path=${junit.java.library.path}"/>
           <classpath location="${dest.base}/testresult/coverage/instrumented" />
           <classpath refid="junitclasspath"/>
           <formatter type="xml" />
           <batchtest todir="${dest.base}/testresult/xml">
             <fileset dir="${dest.base}/classes">
               <exclude name="some/package/that/isnt/tested/*"/>
               <exclude name="**/__Test_*$*" />
               <include name="**/__Test_*.class" />
             </fileset>
           </batchtest>
         </junit>
     </target>

This is searching for all testcases in a directory but it might
also work with Jar-files.

With that and

     <target name="junitreport-html-excl-coverage" depends="junit"
description="Creates html-based reports from tests">
         <junitreport todir="${dest.base}/testresult/html">
           <fileset dir="${dest.base}/testresult/xml">
             <include name="TEST-*.xml"/>
           </fileset>
           <report format="frames" todir="${dest.base}/testresult/html"/>
         </junitreport>
     </target>

you end up with a nice Javadoc-like result of all tests. See
http://ant.apache.org/manual/Tasks/junit.html
and
http://ant.apache.org/manual/Tasks/junitreport.html
for more details.


Regards, Lothar

Messages 23064 - 23093 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