Junit没找到

时间:2018-02-24 14:46:46

标签: java junit

我一直在遵循this very helpful guide on installing junit的步骤,但我遇到了问题。我按照指示创建了这个简单的测试用例:

import junit.framework.TestCase;

public class TestBasic extends TestCase{
    public void testTrue(){
        assertTrue(true);
    }   
}

当我尝试编译时,会发生这种情况:

$ javac TestBasic.java 
TestBasic.java:1: error: package junit.framework does not exist
import junit.framework.TestCase;
                      ^
TestBasic.java:3: error: cannot find symbol
public class TestBasic extends TestCase{
                               ^
  symbol: class TestCase
TestBasic.java:5: error: cannot find symbol
        assertTrue(true);
        ^
  symbol:   method assertTrue(boolean)
  location: class TestBasic
3 errors

这是什么原因?

更多信息:

$ echo $CLASSPATH
:/Users/sahandzarrinkoub/java/junit-X.Y.jar:/Users/sahandzarrinkoub/java/hamcrest-core-XX.YY.jar

内部.bash_profile:

# Java
export JAVA_HOME=/Library/Java/Home
export JUNIT_HOME="$HOME/java"
export PATH="$PATH:$JUNIT_HOME"
export CLASSPATH="$CLASSPATH:$JUNIT_HOME/junit-X.Y.jar:$JUNIT_HOME/hamcrest-core-XX.YY.jar"

〜/ java的内容:

$ cd ~/java
$ ls
TestBasic.java         hamcrest-core-1.3.jar  junit-4.12.jar

0 个答案:

没有答案