1
我無法得到此JUnit測試工作在我正在處理的這個簡單的Java示例上。它的工作原理在Eclipse中而不是在命令行... MVN測試我無法讓JUnit在簡單的Java示例上工作
這裏是我的測試代碼:
import junit.framework.Assert;
import org.junit.Test;
import org.runnablejar.TestJAR.App;
public class TestApp {
@Test
public void testPrintHelloWorld() {
Assert.assertEquals(App.getHelloWorld(), "Hello Worl");
}
}
這裏是我的測試輸出:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building TestJAR
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/jsmith/workspace-sts-3.0.0.RELEASE/TestJAR/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/jsmith/workspace-sts-3.0.0.RELEASE/TestJAR/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 2 source files to /home/jsmith/workspace-sts-3.0.0.RELEASE/TestJAR/target/test-classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/home/jsmith/workspace-sts-3.0.0.RELEASE/TestJAR/src/test/java/TestApp.java:[7,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Test
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Mon Sep 17 20:36:52 EDT 2012
[INFO] Final Memory: 10M/98M
[INFO] ------------------------------------------------------------------------