HomePage
WikiBlog
RecentChanges
LikePages
BackLinks
FindPage

Blog entries

2010-02-16: RSS-Feeds für ricardo.ch-Suchergebnisse

2010-02-15_spam: Disabling public editing

2010-02-15: Show Processes waiting for I/O in Linux

2010-02-13: Sony Vaio P in der Schweiz...

2009-06-17: Wie man plötzlich zum Mörder wird (weil's einfach besser 'rüberkommt!)

2008-05-18: Recreating SSL keys for stunnel, lighttpd and dovecot following the Debian-OpenSSL debacle

2008-02-12: Patch for aoeserver in Kernel 2.6.24

2008-02-07: Usage of open-iscsi on Linux

2008-02-05: Linux and Windows working in harmony with iSCSI

2008-01-19: Linksys PAP2 FXS Port Impedance

< July, 2010 >
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

JUnit Doclet Patches

About my JUnitDoclet patches

JUnitDoclet is a JUnit test-code-generator, which also does incremental updates. This page is devoted to my JUnitDoclet patches. For the time being, there is only one available. Let's see, maybe I there is need for other improvements (and I have the time)!

Exception Handling Patch

Description

My patch adds automatic code generation for exception handling.

Consider the following method:

 public void setPriceCode(int i) throws IllegalPriceException {
   if(i != CHILDRENS || i != REGULAR || i != NEW_RELEASE){
     throw new IllegalPriceException("illegal price code!");
   }
   else { priceCode = i; }
 }

JUnitDoclet now generates the following test automatically:

 public void testSetPriceCode throws Exception {
     // JUnitDoclet begin method getTitle

     //insert code testing basic functionality
     try {
       movie.setPriceCode(null);
     }
     catch (Throwable e) {
       fail("Failed with:" + e);
     }

     //insert code triggering IllegalPriceException
     try {
       movie.setPriceCode(null);
       fail("Should raise IllegalPriceException");
     }
     catch (IllegalPriceException e) {
     }
     catch (Throwable e) {
       fail("Failed with:" + e);
     }
     // JUnitDoclet end method getTitle
 }

Requirements

You need version 1.0.2 of JUnitDoclet.

Download

http://variant.ch/papers/JUnitDocletPatches/JUnitDoclet_exeception_handling.patch

How to apply the patch

To apply the patch, get the source distribution, unzip the src.zip in it and then execute this:

 patch -p1 -u < JUnitDoclet_exeception_handling.patch

Last edited on 7.04.2003 8:15.


View Source | PageHistory | Diff | PageInfo

© Copyright 2004 - 2006 Nicola Fankhauser. All Rights Reserved.