从文件中取测试数据进行单元测试

从文件中取测试数据进行单元测试

 public void testPopSortFromFile() throws IOException
 {
  @SuppressWarnings("unused")
  String line = "";
  FileReader myFileReader = new FileReader ("com/liyingcheng/testFiles/TestPopSort.txt");//相对路径
  BufferedReader myBufferedReader=new BufferedReader(myFileReader);
  while((line = myBufferedReader.readLine())!=null)
  {
   if(line.startsWith("#"))
   {
    continue;
   }
   
   String[] tokens = line.split(",");
   
   int[] actual = {Integer.parseInt(tokens[0]),Integer.parseInt(tokens[1]),Integer.parseInt(tokens[2])};
   int[] expected = {Integer.parseInt(tokens[3]),Integer.parseInt(tokens[4]),Integer.parseInt(tokens[5])};
   testSinglePopSort(expected,actual);
  }
 }


你可能感兴趣的:(从文件中取测试数据进行单元测试)