Bug 398895 - Build successful when unit test fails with ClassNotFoundException
Summary: Build successful when unit test fails with ClassNotFoundException
Status: NEW
Alias: None
Product: Hudson
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Server 2003
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Winston Prakash CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-23 10:51 EST by Stephen McCants CLA
Modified: 2013-03-08 17:32 EST (History)
0 users

See Also:


Attachments
XML output from the unit test. (29.51 KB, text/xml)
2013-01-23 10:51 EST, Stephen McCants CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen McCants CLA 2013-01-23 10:51:18 EST
Created attachment 225987 [details]
XML output from the unit test.

While running Hudson, we noticed that we have unit test files that are completely commented out.  These tests fail with the following error message:

    [junit] Testsuite: com.hcs.orc.data.hl7.MessageProcessorVATest
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    [junit] 
    [junit] Null Test: 	Caused an ERROR
    [junit] com.hcs.orc.data.hl7.MessageProcessorVATest
    [junit] java.lang.ClassNotFoundException: com.hcs.orc.data.hl7.MessageProcessorVATest
    [junit] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    [junit] 	at java.security.AccessController.doPrivileged(Native Method)
    [junit] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    [junit] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    [junit] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    [junit] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    [junit] 	at java.lang.Class.forName0(Native Method)
    [junit] 	at java.lang.Class.forName(Class.java:169)
    [junit] 
    [junit] 
    [junit] Test com.hcs.orc.data.hl7.MessageProcessorVATest FAILED

However, the Hudson build is successful, not unstable as expected.

Attached is the resulting XML file from the unit test run.  

Hudson is picking up this file, as it picks up files in the same directory.  Our "Test Reports XML" configuration option is "**/build/test/results/*.xml".  The failing XML file's results are not visible in Hudson's Test Results for the Job.

Steps to Reproduce:
1) Create a "Unit Test" file that is empty of completely commented out (no import, package or class statements left).
2) Have a Hudson Job build and run this "test".
3) Have the Hudson Job generate a report from the test results XML.
4) This error won't cause the build to be failed or unsuccessful.
Comment 1 Winston Prakash CLA 2013-03-08 12:34:36 EST
Hi Stephen, What builder did you use? I used  Maven3 builder.

- When I completely commented out the Test file, it passed with out any error

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.sample.test.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ TestMavenProject ---
[INFO] Building jar: /Users/wjprakash/Hudson/Eclipse-Hudson/org.eclipse.hudson.core/hudson-war/work/jobs/Test/workspace/target/TestMavenProject-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ TestMavenProject ---
[INFO] Installing /Users/wjprakash/Hudson/Eclipse-Hudson/org.eclipse.hudson.core/hudson-war/work/jobs/Test/workspace/target/TestMavenProject-1.0-SNAPSHOT.jar to /Users/wjprakash/.m2/repository/org/sample/TestMavenProject/1.0-SNAPSHOT/TestMavenProject-1.0-SNAPSHOT.jar
[INFO] Installing /Users/wjprakash/Hudson/Eclipse-Hudson/org.eclipse.hudson.core/hudson-war/work/jobs/Test/workspace/pom.xml to /Users/wjprakash/.m2/repository/org/sample/TestMavenProject/1.0-SNAPSHOT/TestMavenProject-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.454s
[INFO] Finished at: Fri Mar 08 09:26:20 PST 2013
[INFO] Final Memory: 10M/81M
[INFO] ------------------------------------------------------------------------
[DEBUG] Closing connection to remote
[DEBUG] Waiting for process to finish
[DEBUG] Result: 0
Recording test results
Finished: SUCCESS

- However, when keep only the body of the Test empty, I got build failure

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.sample.test.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec
Running org.sample.test.SummaryTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec <<< FAILURE!

Results :

Failed tests: 
  warning(junit.framework.TestSuite$1): No tests found in org.sample.test.SummaryTest

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.880s
[INFO] Finished at: Fri Mar 08 09:30:55 PST 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project TestMavenProject: There are test failures.

Please refer to /Users/wjprakash/Hudson/Eclipse-Hudson/org.eclipse.hudson.core/hudson-war/work/jobs/Test/workspace/target/surefire-reports for the individual test results.
[DEBUG] Closing connection to remote
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project TestMavenProject: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/wjprakash/Hudson/Eclipse-Hudson/org.eclipse.hudson.core/hudson-war/work/jobs/Test/workspace/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[DEBUG] Waiting for process to finish
[DEBUG] Result: 1
Recording test results
Finished: FAILURE
Comment 2 Stephen McCants CLA 2013-03-08 17:17:38 EST
We use Ant scripts mostly built by NetBeans.
Comment 3 Stephen McCants CLA 2013-03-08 17:32:02 EST
My unit test was completely commented out.  For example:

//package com.hcs.orc.data.hl7;
//
//import com.hcs.Server;
...
//@RunWith(JMock.class)
//public class MessageProcessorVATest {
//    private Mockery context;
...
//    @Test
//    public void testCancelVA() throws SQLException {
...
//    }
//}

This is probably bad for a variety of reasons (why we use @Ignore instead, now), so it failing the "unit testing" makes sense.  I would think that would cause Hudson to fail as well (hence this ticket).