Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

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

The Yahoo! Groups Product Blog

Check it out!

Group Information

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

Yahoo! Groups Tips

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

Messages

Advanced
Messages Help
Messages 20302 - 20331 of 24384   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#20302 From: "Francesco" <won_espylacopa@...>
Date: Fri Feb 8, 2008 7:18 am
Subject: Re: Regarding "Annotated descriptions" of new improvements in version 4.4
won_espylacopa
Send Email Send Email
 
--- In junit@yahoogroups.com, "Francesco" <won_espylacopa@...> wrote:
>
> Hello Everyone,
>
> I am interested if the "annotated description" feature can get the
> javadoc method description and adding a textual description to its
> relative generated report. Please can you point me on the right doc or
> give me some sample of this new improvement usage?
>
> Thank You
>

Well, in the meanwhile I solved my needs picking directly the source
code of the Ant JUnit task and patching :p

So if my little patch solution can be useful for other newbies like
me, I put here my solution as simple sample. Serious disclaimer: pick
and use it but don't claim any nuclear disaster :)


*** As note for who can help me, I noticed that a nice thing which I
could do, would be to pick directly the test info content directly
from the source javadoc code method, but I am still searching the
right way to do it :), anyone could point me into the right direction?
Thanks :) ***


However, here It follows all steps to print out a title and a description:

1) download last Ant sources and unpack it, then find XMLConstants,
JUnitVersionHelper, XMLJUnitResultFormatter classes and modify them as
the followings

===org.apache.tools.ant.taskdefs.optional.junit.XMLConstants===
+++>

[...]

     /**
      * title attribute for testcase element
      * @author rigel alias zetatau
      * TODO:
      */
     String ATTR_TITLE = "title";

     /**
      * desc attribute for testcase element
      * @author rigel alias zetatau
      * TODO:
      */
     String ATTR_DESC = "desc";

[...]

<+++


===org.apache.tools.ant.taskdefs.optional.junit.JUnitVersionHelper===
+++>

[...]

public static String getTestCaseTitle(Test test, String
annotationMatch, String annotationParameter) {
     if (test != null) {
    	 if (test.getClass().getName().equals(JUNIT_TESTFACADE))
			 return
helperMethodInvoke(test,annotationMatch,annotationParameter,UNKNOWN);
    	 else
			 return "";
     }
	 return UNKNOWN;
}

public static String getTestCaseDesc(Test test, String
annotationMatch, String annotationParameter) {
     if (test != null) {
    	 if (test.getClass().getName().equals(JUNIT_TESTFACADE))
			 return
helperMethodInvoke(test,annotationMatch,annotationParameter,UNKNOWN);
		 else
			 return "";
     }
	 return UNKNOWN;
}


private static Iterator helperDescriptorCollection(Test facade) {
	 final String
		 junitDescription="org.junit.runner.Description",
		 methodOnFacade="getDescription",
		 methodOnItem="getAnnotations";

	 ArrayList empty = new ArrayList();
	 if (!facade.getClass().getName().equals(JUNIT_TESTFACADE))
		 return empty.iterator();
	 try {

Class.forName(junitDescription,false,ClassLoader.getSystemClassLoader());
			 // otherwise throw an exception
		 Method m = facade.getClass().getMethod(methodOnFacade, new Class[0]);
		 Object itemInstance = m.invoke(facade, new Object[0]);
		 if
(itemInstance!=null&&junitDescription.equals(itemInstance.getClass().getName()))\
{
			 Method m1 = itemInstance.getClass().getMethod(methodOnItem, new
Class[0]);
			 Object rtObj = m1.invoke(itemInstance, new Object[0]);
			 if (rtObj instanceof Collection)
				 return ((Collection)rtObj).iterator();
			 return empty.iterator();
		 } else return empty.iterator();
	 } catch (ClassNotFoundException e) {
	 } catch (SecurityException e) {
	 } catch (IllegalArgumentException e) {
	 } catch (NoSuchMethodException e) {
	 } catch (IllegalAccessException e) {
	 } catch (InvocationTargetException e) {
	 }
	 return empty.iterator();
}

private static Object helperAnnotation(Test façade, String
annotationMatch) {
	 final String methodOnAnnotation="annotationType";
	 Object item=null;
	 Iterator it = helperDescriptorCollection(façade);
	 while (it.hasNext()) {
		 Object a = (Object)it.next();
		 String match = "";
		 try {
			 Method m = a.getClass().getMethod(methodOnAnnotation, new Class[0]);
			 Class out = (Class)m.invoke(a, new Object[0]);
			 match=String.valueOf(out.getName());
		 } catch (SecurityException e) {
		 } catch (NoSuchMethodException e) {
		 } catch (IllegalArgumentException e) {
		 } catch (IllegalAccessException e) {
		 } catch (InvocationTargetException e) {
		 }
		 if (annotationMatch.equals(match)) {
			 item=a;
			 break;
		 }
	 }
	 return item;
}

private static String helperMethodInvoke(Test instance, String
annotationMatch, String methodName, String defaultValue) {
	 try {
// ANNOTATIONS WORKS ONLY ABOVE JDK 1.5
// 	 Iterator it =
((junit.framework.JUnit4TestCaseFacade)instance).getDescription().getAnnotations\
().iterator();
// 	 java.lang.annotation.Annotation item=null;
//    	 while (it.hasNext()) {
//    		 java.lang.annotation.Annotation a =
(java.lang.annotation.Annotation)it.next();
//    		 if (annotationMatch.equals(a.annotationType().getName())) {
//    			 item=a;
//    			 break;
//    		 }
//    	 }
		 Object item = helperAnnotation(instance, annotationMatch);
		 /* No appropriate annotation was found so returns defaultValue */
		 if (item==null)
			 return defaultValue;

		 Method m = item.getClass().getMethod(methodName, new Class[0]);
		 Object oOut = m.invoke(item, new Object[0]);
		 if (oOut instanceof String) {
			 String sOut = String.valueOf(oOut);
			 if ("".equals(sOut)||sOut==null)
				 return defaultValue;
			 else
				 return sOut;
		 } else {
			 return defaultValue;
		 }
	 } catch (SecurityException e) {
	 } catch (IllegalArgumentException e) {
	 } catch (NoSuchMethodException e) {
	 } catch (IllegalAccessException e) {
	 } catch (InvocationTargetException e) {
	 }
	 return defaultValue;
}


[...]

<+++



===org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter===
+++>
public void endTest(Test test) {

[...]

/*
  * This adds additional info to the generated XML test case data,
unfortunately I don't
  * know what ant helper class can give me some params from XML build,
  */
String sTitle =
JUnitVersionHelper.getTestCaseTitle(test,"test.TestInfo","title");
String sDesc =
JUnitVersionHelper.getTestCaseDesc(test,"test.TestInfo","desc");
currentTest.setAttribute(ATTR_TITLE,UNKNOWN.equals(sTitle) ? "" : sTitle);
currentTest.setAttribute(ATTR_DESC,UNKNOWN.equals(sDesc) ? "" : sDesc);

}

[...]

<+++


2) Now build all Ant sources and replace in your default Ant library
environment the old "ant-junit.jar" with the new one.


3) Now you can create an annotation class like this, the name is
important because in the previous class "XMLJUnitResultFormatter" is
literally wired as "test.TestInfo", and if you found a way to retrieve
easily params from build.xml it could be easily parameterized:

===test.TestInfo===

===>
package test;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
  *
  * @author rigel alias zetatau
  *
  */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface TestInfo {
	 /**
	  * Optionally specify test <code>title</code>
	  */
	 public String title() default "Default test title";

	 /**
	  * Optionally specify test <code>description</code>
	  */
	 public String desc() default "Default test description";

	 /**
	  * Optionally specify test <code>error message descriptor</code>
	  */
	 public String errorMessage() default "Default error message descriptor";

}
<===


4) Last step is your class under test, add a TestInfo annotation and
it's all done for the XML testcase data generation (apart xml dtd
another step would be to patch the junit-frames.xsl to show your new
attributes):

===SomeClassUnderTest===

+++>

[...]
	 /**
	  * This test probes if a null argument causes a NPE
	  * @test.regression
	  */
	 @Test(expected=NullPointerException.class)
	 @TestInfo(title="Null argument",
				 desc="This test probes if a null argument causes a NPE")
	 public final void beginTest1() {
		 [...]
	 }

[...]

<+++



--
Francesco V.

#20303 From: "Anirudh Vyas" <anirudhvyas010@...>
Date: Fri Feb 8, 2008 4:55 am
Subject: Re: testing abstract methods
anirudhvyas010
Send Email Send Email
 
Chandima,

Do this : ( emulate the setup ).

I am sorry i have been busy with work so was unable to answer, should
you have questions, it would be better to email me instead as i get
busy and i dont look here.

abstract class SomeClass{

	 public void someMethod(){
		 System.out.println(" Print something");
	 }
}

class A extends SomeClass{

}
public class AssociationMappingTestCase {


	 public  static void main(String[] args){

		 SomeClass a = new A();
		 Method[] methods = a.getClass().getMethods();

		 for(Method aMethod : methods){

			 try {

				 if(!aMethod.isAccessible()){
					 aMethod.setAccessible(true);

					 if(aMethod.getName().equals("someMethod")){
						 aMethod.invoke(a , (Object[]) null);
					 }
				 }




			 } catch (IllegalArgumentException e) {
				 e.printStackTrace();

			 } catch (IllegalAccessException e) {
				 e.printStackTrace();

			 } catch (InvocationTargetException e) {
				 e.printStackTrace();

			 }
		 }
		 // pass =)
		 System.out.println(" OM Namah Shivaya");
	 }

}

Regards
Vyas, Anirudh

#20304 From: "Anirudh Vyas" <anirudhvyas010@...>
Date: Fri Feb 8, 2008 4:49 am
Subject: Re: Testing a listener
anirudhvyas010
Send Email Send Email
 
It would make more sense to me if you post the code. I can understand
code more than people's talk or language, i guess i am not much of
people person :) .

Dont get me wrong, i can understand what you are saying, but i can
debug your code in a better way if you give it to me...
Regards
Vyas, Anirudh

--- In junit@yahoogroups.com, "Jason Davis" <mohadib@...> wrote:
>
> Hello,
>  I am trying to test a parser class I wrote. In my test method I
> invoke the parser method I want to test with
> a string of data. However , the method returns nothing. Its result is
> sent to a listener. How can I test this method
> based on the results it sends to the listener. I hope this makes
sense :s
>
> Thank You,
> jd
>

#20305 From: "Anirudh Vyas" <anirudhvyas010@...>
Date: Fri Feb 8, 2008 4:47 am
Subject: Re: testing abstract clases
anirudhvyas010
Send Email Send Email
 
Hey chandima,

Sorry i wasnt able to answer any sooner, was busy with work ...

So basically i have an abstract class here, ( SomeClass ) and another
class that extends it, so i do the following ...
( As an example i am doing a Print Something so that i know that method
invocation was successful ).

abstract class SomeClass{

      public void someMethod(){
          System.out.println(" Print something");
      }
}

class A extends SomeClass{

}
public class AssociationMappingTestCase {


      public  static void main(String[] args){

          SomeClass a = new A();
          Method[] methods = a.getClass().getMethods();

          for(Method aMethod : methods){

              try {

                  if(!aMethod.isAccessible()){
                      aMethod.setAccessible(true);

                      if(aMethod.getName().equals("someMethod")){
                          aMethod.invoke(a , (Object[]) null);
                      }
                  }




              } catch (IllegalArgumentException e) {
                  e.printStackTrace();

              } catch (IllegalAccessException e) {
                  e.printStackTrace();

              } catch (InvocationTargetException e) {
                  e.printStackTrace();

              }
          }
          // pass =)
          System.out.println(" OM Namah Shivaya");
      }

}



Btw, Use Eclipse, ( or Rational Application Developer if you can get
access to, but i prefer open source tools ), Eclipse 3.x and install
plugins for Red hat developer studio, that will work well.

Regards
Vyas, Anirudh
--- In junit@yahoogroups.com, Chandima R <choi_chandima@...> wrote:
>
> Dear Anirudh
>
>
> I'm testing one abstract parent class that's having 3 child classes
> parent class:  Vehicle
> child classes: Van, Lorry, SmallVan
> unfortunately I have started testing from the parent class because of
it's been abstract how could i test it in JUnit as abstract classes
doesn't let me instantiate(i'm using NetBeans 5.5.1 for my developments)
> by the way thanks , instructing how to test the private methods i got
it done and i realy appriciate your help thank you again
>
> kind regards
> choi chandima
>
>
>
>
>
________________________________________________________________________\
____________
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs
>
> [Non-text portions of this message have been removed]
>

#20306 From: "Rasmus Lock Larsen" <rasmus.lock.larsen@...>
Date: Fri Feb 8, 2008 1:05 pm
Subject: Knowing test-state in tearDown()?
rasmus77
Send Email Send Email
 
Hi.

I would like to dump the state of the system when at test fails.

So I need to know when a test fails before cleaning up the system.

E.g. (java):
protected void tearDown() throws Exception {
    if (testFailed()) {
      dumpStateForDebugging();
    }
    super.tearDown();
}


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

#20307 From: Srinivasan TK <tksri2000@...>
Date: Sat Feb 9, 2008 4:43 am
Subject: Re: Re: <junit> with ANT V 1.6
tksri2000
Send Email Send Email
 
Replacing junit.jar with JUnit version 3.8 doesnt seem
to help.
I am using ant from a standard installation directory
on a box.
I know we need to remove/add to $ANT_HOME/lib
directory if we decide to taskdef junit.
I do not want to go down this path since I will have
to get this change done on the standard instalation
path and there are more than one teams pointing to
this.
Not sure how I can approach the two issues:
1)junit task not recognized in the ant file
2) How to work the changes to lib dir if we decide to
taskdef junit task

Please advise

How do I come up with a solution that is port
--- j_cumps <j_cumps@...> wrote:

>
> What version of junit.jar did you place in ant/lib?
>
> Try if replacing your junit.jar with  JUnit version
> 3.8 solves the
> issue.
>
> Regards, Jan
>
> --- In junit@yahoogroups.com, Srinivasan TK
> <tksri2000@...> wrote:
> >
> > I ran diagnostics on the ant  i am using.
> > I see junit : Missing dependency
> junit.framework.Test
> >
> > for junit..
> > I didnt quite follow the instructions on how to go
> > about this when choosing not to taskdef junit
> task.
> > I appreciate some more help
> >
> > [sngdev03]:/sep/java > ant -diagnostics
> > ------- Ant diagnostics report -------
> > Apache Ant version 1.6.2 compiled on August 5 2004
> >
> > -------------------------------------------
> >  Implementation Version (JDK1.2+ only)
> > -------------------------------------------
> > core tasks     : null
> > optional tasks : 1.6.2
> >
> > -------------------------------------------
> >  ANT_HOME/lib jar listing
> > -------------------------------------------
> > ant.home: /usr/share/ant
> > ant-optional.jar (324076 bytes)
> > activation.jar (25776 bytes)
> > bcel.jar (405813 bytes)
> > ant.jar (645146 bytes)
> > commons-logging.jar (13931 bytes)
> > jakarta-regexp.jar (19405 bytes)
> > java_cup.jar (68499 bytes)
> > junit.jar (34562 bytes)
> > mail.jar (230473 bytes)
> > xalan.jar (1506168 bytes)
> > xerces.jar (1082968 bytes)
> >
> > -------------------------------------------
> >  Tasks availability
> > -------------------------------------------
> > p4opened : Not Available
> > image : Missing dependency
> > com.sun.media.jai.codec.FileSeekableStream
> > sshexec : Missing dependency
> com.jcraft.jsch.UserInfo
> > scp : Missing dependency com.jcraft.jsch.UserInfo
> > cvsversion : Not Available
> > p4changes : Not Available
> > p4versionstring : Not Available
> > ddinit : Not Available
> > jdepend : Missing dependency jdepend.xmlui.JDepend
> > junit : Missing dependency junit.framework.Test
> >
> >
> > --- j_cumps <j_cumps@...> wrote:
> >
> > > If you exactly follow the instructions for Ant
> 1.6,
> > > it will work.
> > >
> > > faq: <style> or <junit> ignores my <classpath> -
> Ant
> > > 1.6.x version
> > >
> > >
> >
>
http://ant.apache.org/faq.html#delegating-classloader-1.6
> > >
> > > JUnit task is optional, but you don't have to
> > > taskdef it.
> > > Try if using JUnit 3.8 solves your problem. I
> think
> > > that full support
> > > for JUnit 4 came with Ant 1.7
> > >
> > > Regards, Jan
> > >
> > > --- In junit@yahoogroups.com, Srinivasan TK
> > > <tksri2000@> wrote:
> > > >
> > > > I am trying to use <junit> target in ANT 1.6
> and
> > > have
> > > > class loader issues as described in this FAQ.
> > > >
> > >
> >
>
http://ant.apache.org/faq.html#delegating-classloader
> > > >
> > > > I am not sure if <junit> is a optional task
> vor
> > > > version 1.6 of ant and I shuld be using
> <taskdef>
> > > to
> > > > define it. If yes..Not sure how to go about
> this.
> > > > Could someone please help .
> > > >
> > > > Sri
> > > >
> > > >
> > > >
> > >
> >
>
______________________________________________________________________
> > > ______________
> > > > Never miss a thing.  Make Yahoo your home
> page.
> > > > http://www.yahoo.com/r/hs
> > > >
> > >
> > >
> > >
> >
> >
> >
> >
>
______________________________________________________________________
> ______________
> > Looking for last minute shopping deals?
> > Find them fast with Yahoo! Search.
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> >
>
>
>



      
________________________________________________________________________________\
____
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. 
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

#20308 From: "J. B. Rainsberger" <jbrains762@...>
Date: Mon Feb 11, 2008 7:35 pm
Subject: Re: Testing a listener
nails762
Send Email Send Email
 
On Feb 2, 2008, at 15:37 , Jason Davis wrote:
> I am trying to test a parser class I wrote. In my test method I
> invoke the parser method I want to test with
> a string of data. However , the method returns nothing. Its result is
> sent to a listener. How can I test this method
> based on the results it sends to the listener. I hope this makes
> sense :s
>
You have already received some answers, but here is a summary of the
technique I use.

I like to check that the event source is generating the right events
at the right times by attaching a mock Listener and intercepting
method calls. In the case of an XML SAX-style parser, you might have a
test like this pseudo-Java test:

testBeginTag:
      mock = mock(ParserListener.class);
      parser = Parser.withListener(mock.proxy());

      mock.expects(once()).method("handleEvent").with(eq(new
BeginTagEvent("html")));

      parser.parse("<html>");

These tests help me know whether Parser sends the right event at the
right time. I might have one more test for multiple listeners:

testMultipleListeners:
      mocks = [mock(ParserListener.class), mock(ParserListener.class),
mock(ParserListener.class)]
      parser = Parser.withManyListeners(mocks.collect { |each|
each.proxy() })
      event = new Event();

      mocks.each { |each|
each.expects(once()).method("handleEvent").with(same(event))) }

      parser.notifyAll(event);

This test helps me know the mechanics of notifying listeners works.

Finally, there is no "testing the listener": the listener is just a
Java class, so there's nothing special you need to do to test it. Just
invoke its handleEvent() method with various event objects and check
what it does. I usually design my listeners as simple delegates to
more model-like classes, so that handleEvent() acts as a Mediator.

I hope this helps.
----
J. B. (Joe) Rainsberger :: http://www.jbrains.ca
Your guide to software craftsmanship
JUnit Recipes: Practical Methods for Programmer Testing
2005 Gordon Pask Award for contributions to Agile Software Practice

#20309 From: "abhishek_hnbgu" <abhishek_hnbgu@...>
Date: Tue Feb 12, 2008 9:55 am
Subject: Configuration problem in Junit.jar
abhishek_hnbgu
Send Email Send Email
 
I am facing some configuration issues related to JUnit.jar.Ca anyone of
please help me out.

#20310 From: "Simon Chappell" <simonpeterchappell@...>
Date: Tue Feb 12, 2008 12:37 pm
Subject: Re: Configuration problem in Junit.jar
spchappell
Send Email Send Email
 
On Feb 12, 2008 3:55 AM, abhishek_hnbgu <abhishek_hnbgu@...> wrote:
>
> I am facing some configuration issues related to JUnit.jar.Ca anyone of
>  please help me out.

I think that it's safe to say that we need more information before we
can help you with this.

What are you trying to use JUnit for? Which version are you trying to
use? Have you read the very helpful FAQ? Which operating system are
you running on? Are you using an IDE and if so, which one?

Here is a link to the JUnit FAQ. It really is very well written and
explains many things, including what you are asking about.

http://junit.sourceforge.net/doc/faq/faq.htm

Simon

--
simonpeter.org | simonpeter.com | newlife-upc.org | wisconsindistrictnews.org

#20311 From: "bala_rajamani" <bala_rajamani@...>
Date: Tue Feb 12, 2008 4:21 pm
Subject: Genearting JUnit HTML reports
bala_rajamani
Send Email Send Email
 
Currently generating junit reports (*.txt and *.xml files) using maven-
surefire-plugin. Wondering is there way to display these reports in
HTML format?

Thanks in advance,
raja.

#20312 From: "Carfield Yim" <carfield@...>
Date: Tue Feb 12, 2008 6:47 pm
Subject: Re: Genearting JUnit HTML reports
c8133594
Send Email Send Email
 
I have same question also, somebody tell me that putting
<reportFormat>HTML</reportFormat> should work. However that doesn't work for
me....

On 2/13/08, bala_rajamani <bala_rajamani@...> wrote:
>
> Currently generating junit reports (*.txt and *.xml files) using maven-
> surefire-plugin. Wondering is there way to display these reports in
> HTML format?
>
> Thanks in advance,
> raja.
>
>
>


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

#20313 From: "Frédéric Camblor" <fcamblor@...>
Date: Tue Feb 12, 2008 6:57 pm
Subject: Re: Genearting JUnit HTML reports
f.camblor
Send Email Send Email
 
You can use the <junitreport> ant task :)

2008/2/12, bala_rajamani <bala_rajamani@...>:
>
>   Currently generating junit reports (*.txt and *.xml files) using maven-
> surefire-plugin. Wondering is there way to display these reports in
> HTML format?
>
> Thanks in advance,
> raja.
>
>
>



--
Frédéric Camblor


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

#20314 From: "James Abley" <james.abley@...>
Date: Wed Feb 13, 2008 11:20 am
Subject: Re: Genearting JUnit HTML reports
taboozizi
Send Email Send Email
 
On 12/02/2008, Frédéric Camblor <fcamblor@...> wrote:
>
>   You can use the <junitreport> ant task :)
>
> 2008/2/12, bala_rajamani <bala_rajamani@...<bala_rajamani%40yahoo.com>
> >:
> >
> > Currently generating junit reports (*.txt and *.xml files) using maven-
> > surefire-plugin. Wondering is there way to display these reports in
> > HTML format?
> >
> > Thanks in advance,
> > raja.
> >
> >
> >
>
> --
> Frédéric Camblor
>
> [Non-text portions of this message have been removed]
>
>
>

This might help?

http://maven.apache.org/plugins/maven-surefire-report-plugin/

I've not used it myself. Alternatively, find an apache project that uses
maven - their website will probably have reports in the format you want, and
you can access the source code (and project poms) to see how they do it.

Cheers,

James


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

#20315 From: "bala_rajamani" <bala_rajamani@...>
Date: Fri Feb 15, 2008 7:37 pm
Subject: Suppressing Junit log level details
bala_rajamani
Send Email Send Email
 
Hello, Currenlty Junit prints all details into the log and the log file
grows to fast and big. So wondering is there a way to control
[suppressing] the details to print only the ERRORs or Warning?

Thanks in advance,

#20316 From: "bala_rajamani" <bala_rajamani@...>
Date: Fri Feb 15, 2008 7:31 pm
Subject: Re: Genearting JUnit HTML reports
bala_rajamani
Send Email Send Email
 
Thanks, I am able to create the HTML reports using Maven report
plugin [maven-surefire-report-plugin].

--- In junit@yahoogroups.com, "James Abley" <james.abley@...> wrote:
>
> On 12/02/2008, Frédéric Camblor <fcamblor@...> wrote:
> >
> >   You can use the <junitreport> ant task :)
> >
> > 2008/2/12, bala_rajamani <bala_rajamani@...<bala_rajamani%
40yahoo.com>
> > >:
> > >
> > > Currently generating junit reports (*.txt and *.xml files)
using maven-
> > > surefire-plugin. Wondering is there way to display these
reports in
> > > HTML format?
> > >
> > > Thanks in advance,
> > > raja.
> > >
> > >
> > >
> >
> > --
> > Frédéric Camblor
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
>
> This might help?
>
> http://maven.apache.org/plugins/maven-surefire-report-plugin/
>
> I've not used it myself. Alternatively, find an apache project that
uses
> maven - their website will probably have reports in the format you
want, and
> you can access the source code (and project poms) to see how they
do it.
>
> Cheers,
>
> James
>
>
> [Non-text portions of this message have been removed]
>

#20317 From: Srinivas Visvanathan <srinivas.visvanathan@...>
Date: Sat Feb 16, 2008 6:42 pm
Subject: Sharing tests in a superclass
srinivas1729
Send Email Send Email
 
Hello junit users

I started using junit in my projects recently. Twice in two days, I
have found a use for something which junit doesn't seem to provide. I
wanted to check if I was doing something wrong.

I have a couple of similar classes A, B, C, that implement the same
interface. So I create test classes TestA, TestB and TestC. But all
the tests in these are really the same, with just different setup. So
I'd like to create a base test class, BaseTest. I'll put all my @Test
methods here. In TestA, TestB and TestC, I'll just have my @Before
methods. When I try to get junit to run my TestA/TestB/TestC, it
doesn't find any tests, because it appears to be looking for tests in
those classes only and not any superclasses. The best I've been able
to do is to override the same test methods in TestA, TestB and TestC,
where each method simply calls the corresponding superclass method.

I'm using junit 4 and doing this in eclipse. Anything wrong in what
I'm doing/assuming ? I've checked the FAQ and done some google
searches, but didn't find anything.

       thanks

       Srinivas

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

#20318 From: Robert Wenner <robert.wenner@...>
Date: Sat Feb 16, 2008 9:43 pm
Subject: Re: Sharing tests in a superclass
robertwenner
Send Email Send Email
 
On Saturday 16 February 2008 12:42, Srinivas Visvanathan wrote:
> I have a couple of similar classes A, B, C, that implement the same
> interface. So I create test classes TestA, TestB and TestC. But all
> the tests in these are really the same, with just different setup. So
> I'd like to create a base test class, BaseTest. I'll put all my @Test
> methods here. In TestA, TestB and TestC, I'll just have my @Before
> methods. When I try to get junit to run my TestA/TestB/TestC, it
> doesn't find any tests, because it appears to be looking for tests in
> those classes only and not any superclasses. The best I've been able
> to do is to override the same test methods in TestA, TestB and TestC,
> where each method simply calls the corresponding superclass method.

I think you're doing it the right way, and it works for me.
Maybe try running your tests on the shell as below? If that works, Eclipse
may be the culprit.

Robert


robert@tiamat:~> cat BaseTest.java
import org.junit.*;

public class BaseTest {
     @Test
     public void theTest() {
         assert(true);
     }
}

robert@tiamat:~> cat DerivedTest.java
import org.junit.*;

public class DerivedTest extends BaseTest {
     @Before
     public void setUp() {
         System.err.println("set up");
     }
}

robert@tiamat:~> javac -cp junit-4.4.jar:. DerivedTest.java

robert@tiamat:~> java -cp junit-4.4.jar:. org.junit.runner.JUnitCore
DerivedTest
JUnit version 4.4
.set up

Time: 0.04

OK (1 test)

#20319 From: "Frédéric Camblor" <fcamblor@...>
Date: Sun Feb 17, 2008 3:11 pm
Subject: Re: Sharing tests in a superclass
f.camblor
Send Email Send Email
 
Maybe you could use some IoC framework such as spring, in order to inject
your "interface implementation" to your test case ?
Another idea, you could design a TestSuite, too, launching several time your
BaseTest with the good implementors setted ?

2008/2/16, Robert Wenner <robert.wenner@...>:
>
>   On Saturday 16 February 2008 12:42, Srinivas Visvanathan wrote:
> > I have a couple of similar classes A, B, C, that implement the same
> > interface. So I create test classes TestA, TestB and TestC. But all
> > the tests in these are really the same, with just different setup. So
> > I'd like to create a base test class, BaseTest. I'll put all my @Test
> > methods here. In TestA, TestB and TestC, I'll just have my @Before
> > methods. When I try to get junit to run my TestA/TestB/TestC, it
> > doesn't find any tests, because it appears to be looking for tests in
> > those classes only and not any superclasses. The best I've been able
> > to do is to override the same test methods in TestA, TestB and TestC,
> > where each method simply calls the corresponding superclass method.
>
> I think you're doing it the right way, and it works for me.
> Maybe try running your tests on the shell as below? If that works, Eclipse
>
> may be the culprit.
>
> Robert
>
> robert@tiamat:~> cat BaseTest.java
> import org.junit.*;
>
> public class BaseTest {
> @Test
> public void theTest() {
> assert(true);
> }
> }
>
> robert@tiamat:~> cat DerivedTest.java
> import org.junit.*;
>
> public class DerivedTest extends BaseTest {
> @Before
> public void setUp() {
> System.err.println("set up");
> }
> }
>
> robert@tiamat:~> javac -cp junit-4.4.jar:. DerivedTest.java
>
> robert@tiamat:~> java -cp junit-4.4.jar:. org.junit.runner.JUnitCore
> DerivedTest
> JUnit version 4.4
> .set up
>
> Time: 0.04
>
> OK (1 test)
>
>



--
Frédéric Camblor


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

#20320 From: Srinivas Visvanathan <srinivas.visvanathan@...>
Date: Mon Feb 18, 2008 7:53 am
Subject: Re: Sharing tests in a superclass
srinivas1729
Send Email Send Email
 
Its working fine for me now, in eclipse. I'm not sure what I was doing
wrong initially.

Thanks for your suggestions and interest.

        Srinivas


On Feb 16, 2008, at 1:43 PM, Robert Wenner wrote:

> On Saturday 16 February 2008 12:42, Srinivas Visvanathan wrote:
> > I have a couple of similar classes A, B, C, that implement the same
> > interface. So I create test classes TestA, TestB and TestC. But all
> > the tests in these are really the same, with just different setup.
> So
> > I'd like to create a base test class, BaseTest. I'll put all my
> @Test
> > methods here. In TestA, TestB and TestC, I'll just have my @Before
> > methods. When I try to get junit to run my TestA/TestB/TestC, it
> > doesn't find any tests, because it appears to be looking for tests
> in
> > those classes only and not any superclasses. The best I've been able
> > to do is to override the same test methods in TestA, TestB and
> TestC,
> > where each method simply calls the corresponding superclass method.
>
> I think you're doing it the right way, and it works for me.
> Maybe try running your tests on the shell as below? If that works,
> Eclipse
> may be the culprit.
>
> Robert
>
> robert@tiamat:~> cat BaseTest.java
> import org.junit.*;
>
> public class BaseTest {
> @Test
> public void theTest() {
> assert(true);
> }
> }
>
> robert@tiamat:~> cat DerivedTest.java
> import org.junit.*;
>
> public class DerivedTest extends BaseTest {
> @Before
> public void setUp() {
> System.err.println("set up");
> }
> }
>
> robert@tiamat:~> javac -cp junit-4.4.jar:. DerivedTest.java
>
> robert@tiamat:~> java -cp junit-4.4.jar:. org.junit.runner.JUnitCore
> DerivedTest
> JUnit version 4.4
> .set up
>
> Time: 0.04
>
> OK (1 test)
>
>



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

#20321 From: Ilja Preuß <it@...>
Date: Tue Feb 19, 2008 8:44 am
Subject: Re: @Ignore with date
ipreussde
Send Email Send Email
 
Any news on this? The runner architecture sounds interesting, not
only for this feature, but also for other ideas I have in mind.

Or, provided that this isn't to be expected in the near future, would
it make sense to include this simple feature without providing the
greater flexibility?

Curious, Ilja

--- In junit@yahoogroups.com, David Saff <saff@...> wrote:
>
> Oh, certainly not "no interest".  I got very interested, but then I
got
> excited about the idea of tagging tests with ids of items in a bug
> database, a la
>
> http://www.developertesting.com/archives/month200608/20060811-
FailingTests.html
>
> This is more appealing to me--tests that stay ignored for any
length of
> time tend to have some sort of metadata in an issue tracker about
them.
> This also allows an interesting workflow: I see a problem with the
code,
> but for some reason, you're the right one to fix it, and you're (
on
> vacation | busy doing something else | mad at me ).  I can open a
bug in
> bugzilla, and then check in a test with @Ignore
(untilBugFixed="12345").
>
> This means that there's a more general idea of @Ignore(if) that I
need
> to get my head around.  And before that, I really want to get the
custom
> runner architecture in better shape, so that you could have built
this
> easily yourself.  And before that, there's settling into a new job,
> which will eventually provide more time and energy to work on JUnit.
>
> So, interested, but distracted...
>
>     David Saff
>
> Ilja Preuß wrote:
> > Mhh, no interest?
> >
> > Is there a low intrusive way I can implement this without having
to
> > patch JUnit with every new version?
> >
> > BTW, there also started some discussion of this feature at
> > http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?
ubb=get_topic&f=68&t=001369
> >
> > --- In junit@yahoogroups.com, it@ wrote:
> >
> >> Hello,
> >>
> >> from time to time, we feel the need to temporarily ignore a test
> >>
> > case. In Junit 3.x, our team introduced a failAfter(Date) method
to
> > remind us from time to time that there was a testcase ignored.
> >
> >> Now that we are switching to JUnit 4, we'd like to use the Ignore
> >>
> > annotation, so I patched it to allow an additional until-
Parameter.
> > Below are the additional unit tests for the TestMethodTest:
> >
> >>  static public class IgnoredUntilTest {
> >> 	 @Ignore(until="1/1/3000") @Test public void
withUntilLater() {}
> >>  }
> >>
> >>  @Test public void ignoreRunnerUntil() {
> >> 	 JUnitCore runner= new JUnitCore();
> >> 	 Result result= runner.run(IgnoredUntilTest.class);
> >> 	 assertEquals(1, result.getIgnoreCount());
> >>  }
> >>
> >>  static public class IgnoredUntilWithTimeTest {
> >> 	 @Ignore(until="1/1/3000 1:00 PM") @Test public void
> >>
> > withUntilLater() {}
> >
> >>  }
> >>
> >>  @Test public void ignoreRunnerUntilWithTime() {
> >> 	 JUnitCore runner= new JUnitCore();
> >> 	 Result result= runner.run
(IgnoredUntilWithTimeTest.class);
> >> 	 assertEquals(1, result.getIgnoreCount());
> >>  }
> >>
> >>  static public class IgnoredUntilBeforeTest {
> >> 	 @Ignore(until="1/1/1900") @Test public void
withUntilBefore() {}
> >>  }
> >>
> >>  @Test public void doNotIgnoreUntilBefore() {
> >> 	 JUnitCore runner= new JUnitCore();
> >> 	 Result result= runner.run
(IgnoredUntilBeforeTest.class);
> >> 	 assertEquals(0, result.getIgnoreCount());
> >>  }
> >>
> >>
> >> The Ignore annotation needs the additional method:
> >>
> >> public @interface Ignore {
> >>  String value() default "";
> >>  String until() default "";
> >> }
> >>
> >> And the implementation of the behaviour is in TestIntrospector:
> >>
> >>  public boolean isIgnored(Method eachMethod) {
> >> 	 Ignore ignoredAnnotation= eachMethod.getAnnotation
(Ignore.class);
> >> 	 if (ignoredAnnotation == null) {
> >> 		 return false;
> >> 	 }
> >> 	 String until= ignoredAnnotation.until();
> >> 	 if (until.length() == 0) {
> >> 		 return true;
> >> 	 }
> >> 	 try {
> >> 		 return DateFormat.getDateTimeInstance
(DateFormat.SHORT,
> >> 				 DateFormat.SHORT,
Locale.ENGLISH).parse(until).after(
> >> 				 new Date());
> >> 	 } catch (ParseException e) {
> >> 		 try {
> >> 			 return DateFormat.getDateInstance
(DateFormat.SHORT,
> >> 					 Locale.ENGLISH).parse
(until).after(new Date());
> >> 		 } catch (ParseException e2) {
> >> 			 return false;
> >> 		 }
> >> 	 }
> >>  }
> >>
> >> (I guess this could be in need of a little refactoring,
sorry... :o )
> >>
> >> If you think it's a good idea, don't hesitate to add it to JUnit
> >>
> > 4.2... :)
> >
> >> Any other comments would be welcome, too, of course.
> >>
> >> Cheers, Ilja
> >>
> >>
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>

#20322 From: "Saju Madhavan" <halex52@...>
Date: Tue Feb 19, 2008 5:52 pm
Subject: junit for with ant 1.6
hsaju
Send Email Send Email
 
Hello

Has any one come across an issue when trying to run junit4 tests using
ant 1.6. Any help would be greally appreciated.
thanks
Honey Alex

junit.framework.JUnit4TestCaseFacade(unknown) Error No tests found in
Mytest

junit.framework.AssertionFailedError: No tests found in Mytest
at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)

#20323 From: "edu_kumar" <sarat.beesa@...>
Date: Wed Feb 20, 2008 1:47 pm
Subject: Scope of the unit test case
edu_kumar
Send Email Send Email
 
Hi all,

I've been unit testing my data access layer with Junit and I ran into
following case..

I was able to successfully mock the db connection for checking the
behavior of my functionality.

For example : I've simulated a 'Connection failure error' and observed
how my code behaves in that particular case. I've a unit test case
which makes sure my functionality is working as per expected behavior.

The method I followed here is simple, I've tried injecting the mock
objects into my code so that my functionality uses the mock objects
instead of actual 'Real Time' Connection object.

But after I finished the whole functionality, I realized that it
didn't work with a 'Real Time' Connection object. I figured out the
reason is that I never worried about the 'Real' connection object when
I was unit testing my code.

My question is..

1) Whose responsibility is to initialize this 'Real' object in my class ?
2) Should my unit tests cover this 'Initializing real time objects' as
well ?
3) What way I can assure that my 'Real' objects are initialized
properly ?

I'm totally stuck here. Any suggestion would be of great help to me..

Thanks in advance.

Sarat

#20324 From: "Nat Pryce" <nat.pryce@...>
Date: Wed Feb 20, 2008 9:02 pm
Subject: Re: Scope of the unit test case
nat_pryce
Send Email Send Email
 
On 20/02/2008, edu_kumar <sarat.beesa@...> wrote:
>  My question is..
>
>  1) Whose responsibility is to initialize this 'Real' object in my class ?

It's the responsibility of the code that creates the object to pass it
the other objects that it depends on.  So, the unit test could pass
mock dependencies to its constructor.  The real code would pass real
dependencies to its constructors.

>  2) Should my unit tests cover this 'Initializing real time objects' as
>  well ?

The unit tests of objects that are made up of other objects (composite
objects) would test the behaviour of those composite objects and,
thereby, test how the internal parts of those composites are
initialised.

End-to-end tests cover the correct initialisation of all the objects
in the system.

Usually a build runs unit tests and then a smoke test that runs a fast
end-to-end test to check for obvious integration errors.  Then it runs
more extensive end-to-end tests to exercise the features that users
care about.

>  3) What way I can assure that my 'Real' objects are initialized
>  properly ?

In TDD, you start with an end-to-end test.  Only when you have a
failing end-to-end test for a given feature do you start drilling down
to write unit tests for individual objects.

--Nat

#20325 From: "edu_kumar" <sarat.beesa@...>
Date: Wed Feb 20, 2008 9:38 pm
Subject: Re: Scope of the unit test case
edu_kumar
Send Email Send Email
 
Hey Nat,

Thanks for your clarifications, but I have couple of questions though..

1) The end-to-end testing sounds more like functional testing to me ,
am I correct ?

2) I was thinking TDD is only used to develop functionality by writing
unit tests first and then the code, can it be more generic to apply
for functional testing ?

3) I need to understand more on this 'end-to-end' testing, are there
any tools available ? or I should rely on the build process for
executing all the test cases for me?

Actually, I've been started using unit-testing tools like Junit
recently for the newly added API in our product but rest of the code
is pretty much legacy in nature. So, i was wondering are there any
tools for doing this end-to-end testing ? just like Junit ?

Thanks anyway for your valuable suggestions..

Sarat.

--- In junit@yahoogroups.com, "Nat Pryce" <nat.pryce@...> wrote:
>
> On 20/02/2008, edu_kumar <sarat.beesa@...> wrote:
> >  My question is..
> >
> >  1) Whose responsibility is to initialize this 'Real' object in my
class ?
>
> It's the responsibility of the code that creates the object to pass it
> the other objects that it depends on.  So, the unit test could pass
> mock dependencies to its constructor.  The real code would pass real
> dependencies to its constructors.
>
> >  2) Should my unit tests cover this 'Initializing real time
objects' as
> >  well ?
>
> The unit tests of objects that are made up of other objects (composite
> objects) would test the behaviour of those composite objects and,
> thereby, test how the internal parts of those composites are
> initialised.
>
> End-to-end tests cover the correct initialisation of all the objects
> in the system.
>
> Usually a build runs unit tests and then a smoke test that runs a fast
> end-to-end test to check for obvious integration errors.  Then it runs
> more extensive end-to-end tests to exercise the features that users
> care about.
>
> >  3) What way I can assure that my 'Real' objects are initialized
> >  properly ?
>
> In TDD, you start with an end-to-end test.  Only when you have a
> failing end-to-end test for a given feature do you start drilling down
> to write unit tests for individual objects.
>
> --Nat
>

#20326 From: "Carfield Yim" <carfield@...>
Date: Thu Feb 21, 2008 3:28 pm
Subject: Re: Scope of the unit test case
c8133594
Send Email Send Email
 
Pick an IoC framework and switch mock and real anytime you wish :-)

On Wed, Feb 20, 2008 at 9:47 PM, edu_kumar <sarat.beesa@...> wrote:
>
>
>
>
>
>
> Hi all,
>
>  I've been unit testing my data access layer with Junit and I ran into
>  following case..
>
>  I was able to successfully mock the db connection for checking the
>  behavior of my functionality.
>
>  For example : I've simulated a 'Connection failure error' and observed
>  how my code behaves in that particular case. I've a unit test case
>  which makes sure my functionality is working as per expected behavior.
>
>  The method I followed here is simple, I've tried injecting the mock
>  objects into my code so that my functionality uses the mock objects
>  instead of actual 'Real Time' Connection object.
>
>  But after I finished the whole functionality, I realized that it
>  didn't work with a 'Real Time' Connection object. I figured out the
>  reason is that I never worried about the 'Real' connection object when
>  I was unit testing my code.
>
>  My question is..
>
>  1) Whose responsibility is to initialize this 'Real' object in my class ?
>  2) Should my unit tests cover this 'Initializing real time objects' as
>  well ?
>  3) What way I can assure that my 'Real' objects are initialized
>  properly ?
>
>  I'm totally stuck here. Any suggestion would be of great help to me..
>
>  Thanks in advance.
>
>  Sarat
>
>

#20327 From: "Saju Madhavan" <halex52@...>
Date: Thu Feb 21, 2008 9:28 pm
Subject: junit4 and cactus.
honeyandsaju
Send Email Send Email
 
I'm wondering if any one is using junit4 with cactus.
What I heard so far is there is no support for Junit4 in cactus.
But there should be some work around. If any one has figured out some
work arounds, would you be kind enough to share it with the group.

thanks
Honey

#20328 From: "Saju Madhavan" <halex52@...>
Date: Thu Feb 21, 2008 9:08 pm
Subject: junit4 and cactus.
hsaju
Send Email Send Email
 
Has any one writing cactus tests in the new junit 4 format (using
annotations). Any insight in this directions would be greatly appreciated.

Saju.

#20329 From: "J. B. Rainsberger" <jbrains762@...>
Date: Thu Feb 21, 2008 3:08 pm
Subject: Re: Re: Scope of the unit test case
nails762
Send Email Send Email
 
On Feb 20, 2008, at 16:38 , edu_kumar wrote:

> Hey Nat,
>
> Thanks for your clarifications, but I have couple of questions
> though..
>
> 1) The end-to-end testing sounds more like functional testing to me ,
> am I correct ?
>
The two are similar enough to call them the same for now. I have found
through years of practice that end-to-end tests are ineffective at
finding integration defects caused by incorrect understanding of the
contract between pairs of objects. I use a design technique based on
collaboration tests and contract tests that drive out integration
defects without integration tests, but it took me a few years of TDD
practice before I felt comfortable with the technique. It's not for
beginners.
> 2) I was thinking TDD is only used to develop functionality by writing
> unit tests first and then the code, can it be more generic to apply
> for functional testing ?
>
I tried doing TDD starting with end-to-end tests, and I found that it
encouraged me to try to write exhaustive end-to-end tests, and that's
where the big problem lies. In order to test a system exhaustively
with end-to-end tests, you typically need a huge number of tests.
Thousands to millions. I can get the same confidence from hundreds to
thousands of object tests. As a result, I use end-to-end tests as a
way to protect against obvious, wide-spread problems, rather than as a
way to check a system carefully for defects. I certainly don't use
them as a starting point for TDD.
> 3) I need to understand more on this 'end-to-end' testing, are there
> any tools available ? or I should rely on the build process for
> executing all the test cases for me?
>
An end-to-end test is simply a test that runs the entire system from
end to end. There's no need for specific tools, although there is
generally a wider selection of appropriate tools for end-to-end
testing compared to more focused object testing.

As for the build executing all the tests, I prefer it, but once again,
if we have too many end-to-end tests, then we become tempted to have
two different builds: a continuous build that doesn't run the end-to-
end tests (because they're too slow) and a nightly build that does run
them (because it takes hours to run them). This slows down feedback
while giving us the illusion of continuous feedback, and I find it too
easy to make serious mistakes that way. This is another reason I
looked for ways to avoid integration defects without end-to-end tests.
> Actually, I've been started using unit-testing tools like Junit
> recently for the newly added API in our product but rest of the code
> is pretty much legacy in nature. So, i was wondering are there any
> tools for doing this end-to-end testing ? just like Junit ?
>
If you have a Java interface for your application, you can use Java-
based tools like JUnit. For web applications, you could use HtmlUnit
or HttpUnit among others. I'm no longer an expert on available tools,
so I'll let others answer this question better than I could.

Take care.
----
J. B. (Joe) Rainsberger :: http://www.jbrains.ca
Your guide to software craftsmanship
JUnit Recipes: Practical Methods for Programmer Testing
2005 Gordon Pask Award for contributions to Agile Software Practice

#20330 From: "Nat Pryce" <nat.pryce@...>
Date: Sat Feb 23, 2008 1:43 pm
Subject: Re: Re: Scope of the unit test case
nat_pryce
Send Email Send Email
 
On 20/02/2008, edu_kumar <sarat.beesa@...> wrote:
>  1) The end-to-end testing sounds more like functional testing to me ,
>  am I correct ?

Yes.  An end-to-end test is a test that tests the system from outside.
  "Edge-to-edge" might be a better term because most systems don't have
"front" and "back" ends.

"End-to-end" also applies to the development process.  I like my
end-to-end test run to build the system from source into deployable
packages and automatically deploy those into a production-like
environment in the same way as a real production release.

>  2) I was thinking TDD is only used to develop functionality by writing
>  unit tests first and then the code, can it be more generic to apply
>  for functional testing ?

In TDD you drive all development with tests.  So, if you want the
system to have a feature you first write a test that demonstrates that
the system doesn't have that feature.  You then work out which classes
need to be be added/modified and do those changes by repeatedly
writing unit-tests, implementing the code, refactoring, and deciding
the next change to make, until eventually the end-to-end test passes.
You then write another end-to-end test.

End-to-end tests give you most feedback about the system's external
quality.  Unit tests give you most feedback about the system's
internal quality.  They also allow you to maximise branch coverage by
running fast (so you can exercise the code with many different input
values) and letting you inject faults (by making mock objects throw
exceptions that are hard to cause in a real system).

In my experience you need both.  System tests tell you when the system
has stopped working.  Unit tests narrow down precisely where the fault
has been introduced.

As the system gets larger, you may use subsystem tests that cover
coarse-grained components like servers, MDBs, etc. However, I have
found those only necessary in systems that were not originally written
with TDD.  In systems that were written from the start with TDD,
components are usually loosely coupled enough to let you run
subsystems in a unit-test fixture.

>  3) I need to understand more on this 'end-to-end' testing, are there
>  any tools available ? or I should rely on the build process for
>  executing all the test cases for me?
>
>  Actually, I've been started using unit-testing tools like Junit
>  recently for the newly added API in our product but rest of the code
>  is pretty much legacy in nature. So, i was wondering are there any
>  tools for doing this end-to-end testing ? just like Junit ?

I use JUnit and a lot of helper code and support libraries to run
end-to-end tests and have the automated build run all the tests, unit
tests and end-to-end tests.  There are many tools for testing
applications end to end, like GUI automation tools, but I've not found
them to fit into a TDD process very well.

--Nat

#20331 From: "edu_kumar" <sarat.beesa@...>
Date: Sun Feb 24, 2008 12:33 am
Subject: Re: Scope of the unit test case
edu_kumar
Send Email Send Email
 
Thank you all for your responses, I think your suggestions, pretty
much answered all my questions..



--- In junit@yahoogroups.com, "Nat Pryce" <nat.pryce@...> wrote:
>
> On 20/02/2008, edu_kumar <sarat.beesa@...> wrote:
> >  1) The end-to-end testing sounds more like functional testing to me ,
> >  am I correct ?
>
> Yes.  An end-to-end test is a test that tests the system from outside.
>  "Edge-to-edge" might be a better term because most systems don't have
> "front" and "back" ends.
>
> "End-to-end" also applies to the development process.  I like my
> end-to-end test run to build the system from source into deployable
> packages and automatically deploy those into a production-like
> environment in the same way as a real production release.
>
> >  2) I was thinking TDD is only used to develop functionality by
writing
> >  unit tests first and then the code, can it be more generic to apply
> >  for functional testing ?
>
> In TDD you drive all development with tests.  So, if you want the
> system to have a feature you first write a test that demonstrates that
> the system doesn't have that feature.  You then work out which classes
> need to be be added/modified and do those changes by repeatedly
> writing unit-tests, implementing the code, refactoring, and deciding
> the next change to make, until eventually the end-to-end test passes.
> You then write another end-to-end test.
>
> End-to-end tests give you most feedback about the system's external
> quality.  Unit tests give you most feedback about the system's
> internal quality.  They also allow you to maximise branch coverage by
> running fast (so you can exercise the code with many different input
> values) and letting you inject faults (by making mock objects throw
> exceptions that are hard to cause in a real system).
>
> In my experience you need both.  System tests tell you when the system
> has stopped working.  Unit tests narrow down precisely where the fault
> has been introduced.
>
> As the system gets larger, you may use subsystem tests that cover
> coarse-grained components like servers, MDBs, etc. However, I have
> found those only necessary in systems that were not originally written
> with TDD.  In systems that were written from the start with TDD,
> components are usually loosely coupled enough to let you run
> subsystems in a unit-test fixture.
>
> >  3) I need to understand more on this 'end-to-end' testing, are there
> >  any tools available ? or I should rely on the build process for
> >  executing all the test cases for me?
> >
> >  Actually, I've been started using unit-testing tools like Junit
> >  recently for the newly added API in our product but rest of the code
> >  is pretty much legacy in nature. So, i was wondering are there any
> >  tools for doing this end-to-end testing ? just like Junit ?
>
> I use JUnit and a lot of helper code and support libraries to run
> end-to-end tests and have the automated build run all the tests, unit
> tests and end-to-end tests.  There are many tools for testing
> applications end to end, like GUI automation tools, but I've not found
> them to fit into a TDD process very well.
>
> --Nat
>

Messages 20302 - 20331 of 24384   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