ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 1066] New - ant / junit integration problem
Date Wed, 21 Mar 2001 16:41:13 GMT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1066

*** shadow/1066	Wed Mar 21 08:41:13 2001
--- shadow/1066.tmp.19887	Wed Mar 21 08:41:13 2001
***************
*** 0 ****
--- 1,93 ----
+ +============================================================================+
+ | ant / junit integration problem                                            |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 1066                        Product: Ant                     |
+ |       Status: NEW                         Version: 1.3                     |
+ |   Resolution:                            Platform: PC                      |
+ |     Severity: Normal                   OS/Version:                         |
+ |     Priority:                           Component: Optional Tasks          |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: ant-dev@jakarta.apache.org                                   |
+ |  Reported By: crocker@inil.com                                             |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ (I've opened this same bug report with the junit team, problem #410157)
+ 
+ Setup: ant(1.3), junit(3.5), jdk(1.3.0_02), win2k 
+ 
+ To validate that I've gotten ant installed and working, I created a build.xml 
+ for use with junit3.5 that simply runs all the tests on junit3.5. From the 
+ command line, it would be something like
+ > java junit.textui.TestRunner junit.samples.AllTests
+ 
+ For ant and it's build.xml, this looks like: 
+ 
+ <project name="JUnit" default="testMe" basedir="."> 
+  <target name="testMe"> 
+   <junit printsummary="yes"> 
+    <formatter type="plain" /> 
+    <test name="junit.samples.AllTests" /> 
+   </junit> 
+  </target> 
+ </project> 
+ 
+ Great. I run "ant" and I get the following output: 
+ C:\junit3.5>ant testMe 
+ Buildfile: build.xml 
+ 
+ testMe: 
+ [junit] Running junit.samples.AllTests 
+ [junit] Tests run: 86, Failures: 0, Errors: 1, Time elapsed: 3.636 sec 
+ [junit] TEST junit.samples.AllTests FAILED 
+ 
+ BUILD SUCCESSFUL 
+ 
+ Total time: 7 seconds 
+ 
+ Trolling through the output, we find: 
+ Testcase: testFilter took 0 sec 
+ Caused an ERROR 
+ null 
+ java.lang.NullPointerException 
+ at junit.runner.BaseTestRunner.getPreference (BaseTestRunner.java:165) 
+ at junit.runner.BaseTestRunner.filterStack (BaseTestRunner.java:194) 
+ at junit.tests.StackFilterTest.testFilter (StackFilterTest.java:45) 
+ at java.lang.reflect.Method.invoke(Native Method) 
+ at junit.framework.TestCase.runTest (TestCase.java:156) 
+ at junit.framework.TestCase.runBare (TestCase.java:130) 
+ at junit.framework.TestResult$1.protect (TestResult.java:106) 
+ at junit.framework.TestResult.runProtected (TestResult.java:124) 
+ at junit.framework.TestResult.run (TestResult.java:109) 
+ at junit.framework.TestCase.run (TestCase.java:121) 
+ at junit.framework.TestSuite.runTest (TestSuite.java:157) 
+ at junit.framework.TestSuite.run (TestSuite.java:152) 
+ at junit.framework.TestSuite.runTest (TestSuite.java:157) 
+ at junit.framework.TestSuite.run (TestSuite.java:152) 
+ at junit.framework.TestSuite.runTest (TestSuite.java:157) 
+ at junit.framework.TestSuite.run (TestSuite.java:152) 
+ at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run 
+ (JUnitTestRunner.java:209) 
+ at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM 
+ (JUnitTask.java:409) 
+ at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute 
+ (JUnitTask.java:283) 
+ at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
+ (JUnitTask.java:263) 
+ at org.apache.tools.ant.Target.execute (Target.java:153) 
+ at org.apache.tools.ant.Project.runTarget (Project.java:898) 
+ at org.apache.tools.ant.Project.executeTarget (Project.java:536) 
+ at org.apache.tools.ant.Project.executeTargets (Project.java:510) 
+ at org.apache.tools.ant.Main.runBuild (Main.java:421) 
+ at org.apache.tools.ant.Main.main (Main.java:149) 
+ 
+ Looking at the source for BaseTestRunner, I see there's some static 
+ initialization code (at the bottom of the class). For some reason, that code 
+ isn't being run when this class is loaded for use with ant. I don't fully 
+ understand WHY that is, but I hacked BaseTestRunner to fix the problem. I moved 
+ the existing initialization code into the method "private static void _init()", 
+ and changed the static initializer code to simply call _init(). I then 
+ changed the method "public static String getPreference (String key)" to test 
+ fPreferences and call _init() if it was null. It got me past the issue.

Mime
View raw message