2017-10-18 11 views
0

GUI에서 텍스트를 testNG assert를 사용하는 텍스트 파일과 비교하려고합니다. GUI를 소스 코드테스트에서 LineBreaks 지정하기

<h2>What is EAC?</h2> 
 
         <br/> 
 
         The Effective Annual Cost (EAC) is a measure ....(text continues...) 
 
[enter image description here][1]

내 텍스트 파일 아래로있다가

EAC 무엇처럼?

은 실제 연간 비용 (EAC)는 (텍스트가 계속 ...)

는 주장이 실패하고 비교 이미지를 부착하지 않는 (공백 문자로 사과를 차이점을 보여줍니다 .... 척도이다. I 아직 허가가 없습니다.)

포럼에서 보았던 줄 바꿈이 있지만 텍스트 파일에 \ n을 추가하려고했으나 사용하지 않았습니다.

제대로 어설트 할 수 있습니까?

답변

0
Issue solved. My mistake was in the Java code I was using to read the text file. 

public String readTextfile(String fileFullPath){ 
    BufferedReader reader= null; 
    StringBuilder stringBuilder = new StringBuilder(); 

     try { 
     reader = new BufferedReader(new FileReader (fileFullPath));  
      String   line = null; 
      //String   ls = System.getProperty("line.separator"); 
      // System.out.println("Line separator is "+ls); 

       while((line = reader.readLine()) != null) { 
        stringBuilder.append(line); 
        //stringBuilder.append(ls); 
        stringBuilder.append("\n"); 
       } 


     } catch (IOException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
     }finally { 
     try{ 
      reader.close(); 
     }catch(Exception e){ 
      e.printStackTrace(); 
     } 
    } 

내 코드는 System.getProperty ("line.separator")를 사용하여 줄 구분 기호를 읽고 줄에 추가하고있었습니다. 위 코드에 표시된대로 새 줄 (\ n)을 추가해야합니다.