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 23049 - 23078 of 24404   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#23049 From: "davexor" <xdavem@...>
Date: Tue Nov 2, 2010 2:09 am
Subject: Question about @Category and @SuiteClasses
davexor
Send Email Send Email
 
Hi there,

Yesterday I was trying out the new features in junit 4.8.x and noticed that
while Categories and SuiteClasses seem to be what I needed to group my tests
into different "testing frameworks" I realized that the xml reports generated
are not what I expected.

The total number of tests I run is around 60k. They're currently grouped into
"testing frameworks" like frontend tests, backend tests, rdbms, api,
webservices, etc. The tests are run through ant and these frameworks are just
filesets that include or exclude different file directories. This seems to work
fine for us, as the reports generated are per-class, so we can quickly know
which class a specific test case belongs to.

The reason I wanted to define my "testing frameworks" using Categories or
SuiteClasses is so that the group definition are closer to the java code and
developers are more in control as opposed to having to manipulate the ant
filesets.

However, when creating a "Frontend" Suite all the test methods in the frontend
test classes are shown in a single report, so I don't know if testMethodA
belongs to com.frontend.ClassATest or com.frontend.ClassBTest.

Is there a way to use Categories or SuiteClasses for my use case?

Thanks!

#23050 From: Kristian Rosenvold <kristian@...>
Date: Tue Nov 2, 2010 4:54 pm
Subject: Running in parallel with categories
krosenvold
Send Email Send Email
 
I've been looking at the possibilities for concurrent test execution in
combination with the use of categories (for maven-surefire
http://jira.codehaus.org/browse/SUREFIRE-656)

What would be the recommended way of doing this? Surefire currently uses
the run(Computer computer, Class<?>... classes) method on junitcore, and
this seems kind of orthogonal to running with categories.

Regards

Kristian Rosenvold

#23051 From: "krosenvold" <kristian@...>
Date: Tue Nov 2, 2010 4:59 pm
Subject: Re: assumeTrue(false) only causes test ignore if called from @BeforeClass method
krosenvold
Send Email Send Email
 
+1 to this David. I work on maven-surefire and will gladly implement
whatever this bold decision may be  ;)

Kristian

--- In junit@yahoogroups.com, David Saff <david@...> wrote:
>
> Kent,
>
> It's more about making a bold once-for-all decision about how failing
> assumptions are communicated, and then informing/persuading the
> various runners to pick up on that communication.



>
>    David Saff
>
> On Fri, Oct 22, 2010 at 10:41 AM, Kent Beck <kentb@...> wrote:
> > So are we missing one or more test cases or is the problem subtler than
that?
> >
> > Kent
> >
> > On Oct 22, 2010, at 5:57 AM, David Saff wrote:
> >
> >> Vince,
> >>
> >> We need to do a better job with this. Failing assumptions changed the
> >> interface for JUnit to include tests that could be "ignored" halfway
> >> through their execution, and we need to work with the maven and
> >> Eclipse runner implementors to make sure that we output something they
> >> can ingest. Thank you for the reminder.
> >>
> >> David Saff
> >>
> >> On Thu, Oct 21, 2010 at 6:58 PM, vinceharron <vince@...> wrote:
> >> > I've tried this on JUnit 4.7 and 4.8.2. I hope one of you can point out
something I'm doing wrong.
> >> >
> >> > assumeTrue(false) only causes ignore if called from @BeforeClass method.
I was hoping that assumeTrue(false) called at any point would cause an Ignore
result.
> >> >
> >> > http://kentbeck.github.com/junit/javadoc/latest/
> >> > "The default JUnit runner treats tests with failing assumptions as
ignored."
> >> >
> >> > I'm running my tests with both Maven and Eclipse's JUnit 4 UI. Both have
the same results.
> >> >
> >> > As I understand the JUnit docs, all three of these tests should be
ignored/skipped.
> >> >
> >> > Running com.mycompany.app.AssumeTest
> >> > Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec
> >> > Running com.mycompany.app.AssumeBeforeTest
> >> > Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
> >> > Running com.mycompany.app.AssumeBeforeClassTest
> >> > Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.006 sec
> >> >
> >> > public class AssumeTest
> >> > {
> >> >  @Test
> >> >  public void test()
> >> >  {
> >> >    assumeTrue(false);
> >> >    assertTrue(false);
> >> >  }
> >> > }
> >> >
> >> > public class AssumeBeforeTest
> >> > {
> >> >  @Before
> >> >  public void before()
> >> >  {
> >> >    assumeTrue(false);
> >> >  }
> >> >
> >> >  @Test
> >> >  public void test()
> >> >  {
> >> >    assertTrue(false);
> >> >  }
> >> > }
> >> >
> >> > public class AssumeBeforeClassTest
> >> > {
> >> >  @BeforeClass
> >> >  public static void before() {
> >> >    assumeTrue(false);
> >> >  }
> >> >
> >> >  @Test
> >> >  public void test()
> >> >  {
> >> >    assertTrue(false);
> >> >  }
> >> > }
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > ------------------------------------
> >> >
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>

#23052 From: David Saff <david@...>
Date: Tue Nov 2, 2010 5:43 pm
Subject: Re: Running in parallel with categories
dsaff
Send Email Send Email
 
Kristian,

That's a good question.  If you create a suite using the Categories
runner, you should be all set to run it using whatever Computer you
want.  I assume you're asking how one could do this without an
explicit categorized suite?

    David Saff

On Tue, Nov 2, 2010 at 12:54 PM, Kristian Rosenvold
<kristian@...> wrote:
> I've been looking at the possibilities for concurrent test execution in
> combination with the use of categories (for maven-surefire
> http://jira.codehaus.org/browse/SUREFIRE-656)
>
> What would be the recommended way of doing this? Surefire currently uses
> the run(Computer computer, Class<?>... classes) method on junitcore, and
> this seems kind of orthogonal to running with categories.
>
> Regards
>
> Kristian Rosenvold
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23053 From: Kristian Rosenvold <kristian@...>
Date: Tue Nov 2, 2010 8:22 pm
Subject: Re: Running in parallel with categories
krosenvold
Send Email Send Email
 
Yes that solution is supported already; you can force surefire to use
the 4.7 provider and just run an explicitly coded suite as the build
target using <includes> statements.

To my (relatively limited knowledge) the missing functionality is really
just to be able to pass in the category name as a string parameter,
probably using the groups parameter which is implemented for testng
(http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#groups).


Surefire already scans the entire classpath looking for tests, so I
assume we'd be able to resolve the string to one or more java classes
(possibly working backwards from @Category annotations we find when
scanning the classpath). Then we could just dynamically create
a test suite and send it in, doing something like the answer in this
question:
http://stackoverflow.com/questions/1070202/junit-suiteclasses-with-a-static-list\
-of-classes


Would that be the way to go ?

Kristian




ti., 02.11.2010 kl. 13.43 -0400, skrev David Saff:
>
> Kristian,
>
> That's a good question. If you create a suite using the Categories
> runner, you should be all set to run it using whatever Computer you
> want. I assume you're asking how one could do this without an
> explicit categorized suite?
>
> David Saff
>
> On Tue, Nov 2, 2010 at 12:54 PM, Kristian Rosenvold
> <kristian@...> wrote:
> > I've been looking at the possibilities for concurrent test execution
> in
> > combination with the use of categories (for maven-surefire
> > http://jira.codehaus.org/browse/SUREFIRE-656)
> >
> > What would be the recommended way of doing this? Surefire currently
> uses
> > the run(Computer computer, Class<?>... classes) method on junitcore,
> and
> > this seems kind of orthogonal to running with categories.
> >
> > Regards
> >
> > Kristian Rosenvold
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
>
>

#23054 From: David Saff <david@...>
Date: Thu Nov 4, 2010 11:38 am
Subject: Re: Running in parallel with categories
dsaff
Send Email Send Email
 
On Tue, Nov 2, 2010 at 4:22 PM, Kristian Rosenvold
<kristian@...> wrote:
> Yes that solution is supported already; you can force surefire to use
> the 4.7 provider and just run an explicitly coded suite as the build
> target using <includes> statements.
>
> To my (relatively limited knowledge) the missing functionality is really
> just to be able to pass in the category name as a string parameter,
> probably using the groups parameter which is implemented for testng
> (http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#groups).

Yes, that's not in the current implementation.

> Surefire already scans the entire classpath looking for tests, so I
> assume we'd be able to resolve the string to one or more java classes
> (possibly working backwards from @Category annotations we find when
> scanning the classpath). Then we could just dynamically create
> a test suite and send it in, doing something like the answer in this
> question:
>
http://stackoverflow.com/questions/1070202/junit-suiteclasses-with-a-static-list\
-of-classes
>
>
> Would that be the way to go ?

Yep.  Also, have you seen Dale Emery's DynamicSuite?  I might have the
name wrong.

    David Saff

>
> Kristian
>
>
>
>
> ti., 02.11.2010 kl. 13.43 -0400, skrev David Saff:
>>
>> Kristian,
>>
>> That's a good question. If you create a suite using the Categories
>> runner, you should be all set to run it using whatever Computer you
>> want. I assume you're asking how one could do this without an
>> explicit categorized suite?
>>
>> David Saff
>>
>> On Tue, Nov 2, 2010 at 12:54 PM, Kristian Rosenvold
>> <kristian@...> wrote:
>> > I've been looking at the possibilities for concurrent test execution
>> in
>> > combination with the use of categories (for maven-surefire
>> > http://jira.codehaus.org/browse/SUREFIRE-656)
>> >
>> > What would be the recommended way of doing this? Surefire currently
>> uses
>> > the run(Computer computer, Class<?>... classes) method on junitcore,
>> and
>> > this seems kind of orthogonal to running with categories.
>> >
>> > Regards
>> >
>> > Kristian Rosenvold
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>>
>>
>>
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23055 From: Dale Emery <dale@...>
Date: Thu Nov 4, 2010 11:47 am
Subject: Re: Running in parallel with categories
dhemery...
Send Email Send Email
 
Hi David and Kristian,

> Yep. Also, have you seen Dale Emery's DynamicSuite? I might have the name
> wrong.
>
It's currently called RuntimeSuite:
https://github.com/dhemery/runtime-suite

I do think DynamicSuite would be a better name. Not sure if I want to annoy
my (nearly 2) fanatic users by changing the name.

Dale

--
Dale Emery
Consultant to software teams and leaders
Web: http://dhemery.com


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

#23056 From: Andrew Feller <andrew.feller@...>
Date: Thu Nov 4, 2010 11:47 am
Subject: Recommendations for tests on transcoding strings
andrew.feller@...
Send Email Send Email
 
Hello everyone,

I am developing JUnit tests for transcoding ISO-8859-1 strings into UTF-8
and having difficulties with the correct approach to take.  The problem is
that some of the test cases deal with characters not supported within
ISO-8859-1 such as  or .  I know Java supports encoding strings in
specific character sets via String.getBytes(Charset charset) and that new
strings can be constructed via new String(byte[] bytes, Charset charset).

QUESTIONS:

    1. Is the recommended way to test transcoding simply to test resulting
    bytes from encoding?
    2. If test resulting bytes from encoding, is there a recommended way to
    determine the correct bytes for the unit test?
    3. Does anyone know of existing unit tests that address this problem?

I would appreciate any advice and direction offered.

Regards,
--
*Andrew Feller*
Production Engineer
Bronto Software, Inc
324 Blackwell St. Ste. 410
Durham, NC 27701

"If you do too much, people get dependent on you.
And if you do nothing, they lose hope.
You have to use a light touch ...
If you do things right, people won't be sure you've done anything at all."

-- Gaseous Omniscient Deity from Futurama


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

#23057 From: jp_listero <jgarbora@...>
Date: Tue Nov 9, 2010 5:07 pm
Subject: ANT
jgarbora
Send Email Send Email
 
http://junit.sourceforge.net/doc/faq/faq.htm#running_5

Hi,

I'm using cruiseControl ... And I need to configure ant to run my Junits ...

I known that the info. is in the FAQ, but I dont known where I must
put that configuration.

faq from junit
http://junit.sourceforge.net/doc/faq/faq.htm#running_5

and faq from cruiseControl:
Perhaps the JUnit results are not being captured correctly. Ensure
that your <junit> ant task contains the proper formatting directive to
instruct JUnit to output the results in XML format: <formatter
type="xml"/>. If you are directing JUnit to send output to a
subdirectory, make sure to tell CC about it - use the <merge> element
in the <log> section of your config.xml.

someone can help me ?

I'm using Netbeans 6.8 and Junit 4.5

thanks

#23058 From: Thomas Dempton <t.dempton@...>
Date: Fri Nov 12, 2010 1:52 pm
Subject: Howto run JUnit4 tests from command-line?
t.dempton
Send Email Send Email
 
Hi,

I try to run my JUnit4 tests from the command-line using the following command:
> java -cp ... org.junit.runner.JUnitCore pkg.Test1 pkg.Test2"

However it seems using this command my "@BeforeClass"-Annotations are ignored.
When I select "run" in netbeans everything executes like expected.

Any idea why?

Thank you in advance, Thomas





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

#23059 From: Thomas Dempton <t.dempton@...>
Date: Fri Nov 12, 2010 12:09 pm
Subject: Howto specify classpath for junit tests?
t.dempton
Send Email Send Email
 
Hi,

I would like to execute my JUnit-4 tests as an ant task.

However I've troubles setting the classpath, my jars are listed in a property
called "exec-cp",
however JUnit always aborts with ClassNotFound.

Any idea whats wrong?

Thanks you in advance, Thomas


   <property name="exec-cp" value="${gen.classpath}:${build}"/> <!-- Something
like lib/a.jar:lib/b.jar .... >

    <target name="run-client" depends="build" description="Executes the client">
       <junit>
     <classpath location="${exec-cp}"/>
     <formatter type="brief" usefile="false" />
     <test name="pkg.Test1" />
     <test name="pkg.Test2" />
     </junit>
    </target>





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

#23060 From: David Saff <david@...>
Date: Fri Nov 12, 2010 3:22 pm
Subject: Re: Howto specify classpath for junit tests?
dsaff
Send Email Send Email
 
Thomas:

a) While many people on this list use ant, and I hope one of us can
help you, you may find more ant experts on an ant-specific list.
b) Which class is reported not found?

    David Saff

On Fri, Nov 12, 2010 at 7:09 AM, Thomas Dempton <t.dempton@...> wrote:
> Hi,
>
> I would like to execute my JUnit-4 tests as an ant task.
>
> However I've troubles setting the classpath, my jars are listed in a property
> called "exec-cp",
> however JUnit always aborts with ClassNotFound.
>
> Any idea whats wrong?
>
> Thanks you in advance, Thomas
>
>
> <property name="exec-cp" value="${gen.classpath}:${build}"/> <!-- Something
> like lib/a.jar:lib/b.jar .... >
>
>  <target name="run-client" depends="build" description="Executes the client">
>   <junit>
>  <classpath location="${exec-cp}"/>
>  <formatter type="brief" usefile="false" />
>  <test name="pkg.Test1" />
>  <test name="pkg.Test2" />
>  </junit>
>  </target>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23061 From: David Saff <david@...>
Date: Fri Nov 12, 2010 3:23 pm
Subject: Re: Howto run JUnit4 tests from command-line?
dsaff
Send Email Send Email
 
Are your @BeforeClass annotations on Test1 and Test2, or on a suite
not mentioned?

    David Saff

On Fri, Nov 12, 2010 at 8:52 AM, Thomas Dempton <t.dempton@...> wrote:
> Hi,
>
> I try to run my JUnit4 tests from the command-line using the following
command:
>> java -cp ... org.junit.runner.JUnitCore pkg.Test1 pkg.Test2"
>
> However it seems using this command my "@BeforeClass"-Annotations are ignored.
> When I select "run" in netbeans everything executes like expected.
>
> Any idea why?
>
> Thank you in advance, Thomas
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#23062 From: "David" <davids@...>
Date: Tue Nov 16, 2010 1:54 am
Subject: Running JUnit tests from a separate Java application
dljande
Send Email Send Email
 
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

#23063 From: David Saff <david@...>
Date: Tue Nov 16, 2010 2:16 am
Subject: Re: Running JUnit tests from a separate Java application
dsaff
Send Email Send Email
 
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
>
>
>
>

#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]

Messages 23049 - 23078 of 24404   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