2014-11-24 4 views
0

최근에 tdd로 게임을 시작했는데 왜 한 가지가 작동하고 다른 하나가 작동하지 않는지 이해할 수없는 문제가 발생했습니다.IntelliJ IDEA의 DataProvider에서 TestNG 테스트를 수행하지 못했습니다.

다음 코드는 나를 위해 작동 :

public class Ant { 

    public Ant(Point startLocation, Point hive) { 
     this.currentLocation = new Point(startLocation); 
     this.hive = new Point(hive); 
    } 

    public void goHome() { 
     if (hive.x > currentLocation.x) { 
      currentLocation.x++; 
     } else if (hive.x < currentLocation.x){ 
      currentLocation.x--; 
     } 
     if (hive.y > currentLocation.y) { 
      currentLocation.y++; 
     } else if (hive.y < currentLocation.y){ 
      currentLocation.y--; 
     } 
    } 
} 

상응하는 시험 :

@DataProvider(name = "goneHome") 
public static Object[][] goHome() { 
    return new Object[][] { 
      {new Point(2,1), new Point(3,2), new Point(7,8)}, 
      {new Point(20,1), new Point(19,2), new Point(7,8)}, 
      {new Point(23,10), new Point(22,9), new Point(7,8)}, 
      {new Point(2,10), new Point(3,9), new Point(7,8)}, 
      {new Point(2,8), new Point(3,8), new Point(7,8)}, 
      {new Point(7,1), new Point(7,2), new Point(7,8)} 
    }; 
} 

@Test(dataProvider = "goneHome") 
public void testGoHome(Point currentPosition, Point nextPosition, Point hive) 
    throws Exception { 
    Ant ant = new Ant(currentPosition, hive); 

    ant.move(); 
    assertEquals(ant.getCurrentLocation(), nextPosition); 
} 

테스트가 실패 나는이 같은 개미 생성자 변경하는 경우 : 실패함으로써

public Ant(Point startLocation, Point hive) { 
    this.currentLocation = startLocation; 
    this.hive = hive; 
} 

을 즉, DataProvider의 처음 두 세트를 사용한 테스트가 올바르게 작동하고 나머지는 실패/완료되지 않은 것입니다. 지. 나는 무엇이 실패했는지 잘 모르겠다. DataProvider에서 처음 두 세트의 데이터를 제거하면 여전히 첫 번째 두 데이터 세트 (이전에 셋째 및 네 번째 데이터 세트가 있던 위치)가 실패하지 않습니다.

나는 IntelliJ을 사용하며 "실패한"테스트 이외의 기호는 여전히 "로드 아이콘"입니다.

각 단일 테스트 케이스를 디버깅하면 점이 올바르게 설정되었음을 알 수 있습니다. 테스트에서 어설 션을 제거해도 아무런 변화가 없습니다.

다른 사람이 나에게이 행동을 설명해 주시겠습니까? 사전

에곤

편집에

감사합니다 :

+0

테스트를 Maven 목표로 실행하려고 시도 했습니까? 어쩌면 아이디어가 버그 –

+0

인데, 그것은 maven과 함께 작동했습니다. 감사합니다! 나는 이것에 대해 너무 오랫동안 생각해 보았다. ^^ –

+0

똑똑한 도구라도 실패 할 수있다. –

답변

1

은 어쩌면하게 IntelliJ IDEA에서 버그 실패한 생성자의 버전을 수정. 때때로 나는 또한이 문제에 직면 해있다. 불행히도 아직 해결되지 않았습니다 (2014-11-24). https://youtrack.jetbrains.com/issue/IDEA-100752

대체 러너로 테스트를 실행 해보십시오 (예 : Maven 목표).

+0

덕분에 Maven과 함께 일했다. 나는 이것에 대해 너무 오랫동안 생각을 보냈다. 미안하다. 나는 stackoverflow에 익숙하다. –