私の教授が私に教えてくれた単体テストに少し問題があります。コンパイル時に、私は次のエラーを受け取る:
cannot find symbol import org.junit.Assert.assertArrayEquals; cannot find symbol import org.junit.Assert.assertEquals; import org.junit.Assert.assertFalse; import org.junit.Assert.assertTrue;
org.junit.Assertのインポートでエラーが発生しました
私はJUnitのをダウンロードしていると私は似たファイルをコンパイルすることができ、なぜ私はこれで問題が発生していますか? コードは次のとおりです。
import java.util.Comparator;
import org.junit.Assert.assertArrayEquals;
import org.junit.Assert.assertEquals;
import org.junit.Assert.assertFalse;
import org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
public class SortingTests {
class IntegerComparator implements Comparator<Integer> {
@Override
public int compare(Integer i1, Integer i2) {
return i1.compareTo(i2);
}
}
private Integer i1,i2,i3;
private OrderedArray<Integer> orderedArray;
@Before
public void createOrderedArray(){
i1 = -12;
i2 = 0;
i3 = 4;
orderedArray = new OrderedArray<>(new IntegerComparator());
}
@Test
public void testIsEmpty_zeroEl(){
assertTrue(orderedArray.isEmpty());
}
@Test
public void testIsEmpty_oneEl() throws Exception{
orderedArray.add(i1);
assertFalse(orderedArray.isEmpty());
}
@Test
public void testSize_zeroEl() throws Exception{
assertEquals(0,orderedArray.size());
}
}
のようなメソッドを参照おそらく瓶がありますクラスパスではありません。それを確認していただけますか?どの瓶を使っているのか教えてください。 – DNAj
私はJUnit 4.12を使用していますが、jarはクラスパス内になければなりません。私は同じフォルダで同じようなテストをコンパイルすることができます。 – Leo
私はクラスパスで間違いをしていました。助けてくれてありがとう。 – Leo