我正在尝试测试我的 3 个以不同方式对字符串数组进行排序的类!
我知道有一种方法可以初始化一个数组,然后在我的每一个测试中使用它们。
到目前为止,这是我的代码:
public class SortingTest {
public insertionSort is = new insertionSort();
public bubbleSort bs = new bubbleSort();
@Test
public void testBubbleSort() {
String [] sortedArray ={"Chesstitans", "Ludo", "Monkey", "Palle"};
bs.sort(sortedArray);
assertArrayEquals(sortedArray, x);
}
@Test
public void testInsertionSort() {
}
@Test
public void testMergeSort() {
}
@Test
public void testSelectionSort() {
}
@Before
protected void setUp() throws Exception{
String[]x ={"Ludo", "Chesstitans", "Palle", "Monkey"};
}
}
尽管我已经尝试了 setUp 和 initialize 方法,但它似乎没有找到 x 我做错了什么?