ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 4897] New: - Functionality request/patch for JUnit BatchTest
Date Thu, 15 Nov 2001 19:30:16 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4897>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4897

Functionality request/patch for JUnit BatchTest

           Summary: Functionality request/patch for JUnit BatchTest
           Product: Ant
           Version: 1.4.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Optional Tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: sanderson@bonddesk.com


Background:

Java source file conventions typically dictate that the source file directory
structure follows that of the packages within. For example, a package of name 
com.company.module.foo would reside in src/com/company/module/foo. This works
fine if the entire project is Java-based.

However, in many large environments (such as that of our own), projects
encompass many different languages, such as SQL, C, C++, and Java. One of 
the easiest ways to organize large projects of this nature is to commingle the
sourcecode by module, not by language type. For example:

src/module/submodule/prog.c
src/module/submodule/proc.sql
src/module/submodule/Class.java
src/module/submodule/test/ClassTest.java

Where Class.java has a package of com.company.module.submodule.

Few other languages are dependent upon directory structures like Java (Python is
one example; Python modules are defined by directory). However, Java 
does not *require* that the source code directory match the package name. The
above example will compile com.company.module.submodule.Class 
correctly. Additionally, since Java is but one of many languages in this
project, it doesn't make much sense to force a 
src/com/company/module/submodule directory structure for the C or SQL code as well.

The Point:

The JUnit optional task BatchTest task does not take the above code organization
into account, and assumes that the directory given in the fileset also 
defines the package structure. Therefore, running a BatchTest on the above
directory structure with the fileset based at src/ would result in BatchTest not 
being able to find the class "module.submodule.test.ClassTest" instead of
"com.company.module.submodule.test.ClassTest".

The Patch:

The following patch adds a "prepend" attribute to the BatchTest task, allowing
the use of the above directory structure in this manner:

	<batchtest fork="yes" todir="somedir" prepend="com.company">
	  <fileset dir="${src}">
	    <include name="**/test/*Test*.java" />
	  </fileset>
	</batchtest>


--- src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java.orig	Thu Nov 15 13:20:39
2001
+++ src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java	Thu Nov 15 13:24:31
2001
@@ -85,6 +85,9 @@
     /** the list of filesets containing the testcase filename rules */
     private Vector filesets = new Vector();
 
+    /** the string to prepend to classnames */
+    private String classnamePrepend = null;
+
     /**
      * create a new batchtest instance
      * @param project     the project it depends on.
@@ -93,6 +96,14 @@
         this.project = project;
     }
 
+    public void setPrepend(String prepend) {
+        this.classnamePrepend = prepend;
+    }
+
+    public String getPrepend() {
+        return classnamePrepend;
+    }
+
     /**
      * Add a new fileset instance to this batchtest. Whatever the fileset is,
      * only filename that are <tt>.java</tt> or <tt>.class</tt> will
be
@@ -137,6 +148,8 @@
         JUnitTest[] tests = new JUnitTest[filenames.length];
         for (int i = 0; i < tests.length; i++) {
             String classname = javaToClass(filenames[i]);
+
    if (classnamePrepend != null)
+
	classname = classnamePrepend + "." + classname;
             tests[i] = createJUnitTest(classname);
         }
         return tests;

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message