testng을 처음 사용했습니다. 명령 줄에서 실행하면 Expected and Actual 메시지를보고 싶습니다. 내 IDE에서 실행하면 , 그것은 작동합니다testng 얻는 방법 명령 줄에서 메시지 실패
java org.testng.TestNG -testclass SimpleTest
내가 얻을 :
Command line suite Total tests run: 2, Failures: 2, Skips: 0
(어떤 메시지)
java.lang.AssertionError: Expected :3 Actual :2
내가 사용하여 명령 줄에서 실행할 때 try ... catch 블록에 테스트를 래핑하면 다음과 같이 표시됩니다.
try{
int x = 3;
Assert.assertEquals(2,x);
} catch (AssertionError ae){
System.out.println(ae.getMessage());
}
내 메시지가 나타납니다.
expected:<3> but was:<2>
이것은 테스트를 코드 작성하는 깨끗한 방법이 아닌 것처럼 보입니다. 어떻게 할 건데?
감사합니다. 이것은 testng API에 들어가기위한 훌륭한 연습입니다. – mcgyver5