연구 프로젝트 용 테스트 코드를 설치하고 있습니다. 우리는 같은프로그래밍 방식으로 테스트 케이스에서 try/catch 블록을 제거하십시오.
@Test
public void test025() throws Throwable {
if (debug)
System.out.format("%n%s%n", "RegressionTest1.test025");
java.lang.Double[] d_array2 = new java.lang.Double[] { 1.0d, (-1.0d) };
org.apache.commons.math.linear.ArrayRealVector arrayRealVector3 = new org.apache.commons.math.linear.ArrayRealVector(d_array2);
org.apache.commons.math.linear.ArrayRealVector arrayRealVector4 = new org.apache.commons.math.linear.ArrayRealVector(d_array2);
try {
org.apache.commons.math.linear.ArrayRealVector arrayRealVector7 = new org.apache.commons.math.linear.ArrayRealVector(d_array2, (int) '4', (int) ' ');
org.junit.Assert.fail("Expected exception of type org.apache.commons.math.exception.NumberIsTooLargeException");
} catch (org.apache.commons.math.exception.NumberIsTooLargeException e) {
}
org.junit.Assert.assertNotNull(d_array2);
}
어설 문으로 된 .java 파일에서 주석 테스트 케이스로 시작 : 다음
original = original.replace("org.junit.Assert.", "//org.junit.Assert.");
original = original.replace("assert", "//assert");
, 그들은 예외를 로그와 Javassist로 지정되어 있습니다 (그들은 확인하기 테스트 케이스의 모든 실행)에서 발생 :
for (CtMethod testmethod : methods) {
if (testmethod.getName().startsWith("test")) {
try {
testmethod.insertBefore("semanticrt.statedump.dumpObjectState.setDumpTestCase(\""+testClassName+ "." + testmethod.getName()+"\");");
CtClass etype = null;
try {
etype = pool.get("java.lang.Exception");
} catch (NotFoundException e) {
e.printStackTrace();
}
String exceptionCode = "{ semanticrt.statedump.dumpObjectState.dumpExceptionToFile($e, " +
"\"" + outputFileRoot + "."+ testmethod.getName() + ".exception\", false); throw $e; }\n";
testmethod.addCatch(exceptionCode, etype);
} catch (CannotCompileException e) {
System.out.println(testmethod);
e.printStackTrace();
}
}
}
산출 어느 :
@Test
public void test025() throws Throwable {
try {
dumpObjectState.setDumpTestCase("RegressionTest1.test025");
if(debug) {
System.out.format("%n%s%n", new Object[]{"RegressionTest1.test025"});
}
Double[] var1 = new Double[]{Double.valueOf(1.0D), Double.valueOf(-1.0D)};
new ArrayRealVector(var1);
new ArrayRealVector(var1);
try {
new ArrayRealVector(var1, 52, 32);
} catch (NumberIsTooLargeException var6) {
;
}
} catch (Exception var7) {
dumpObjectState.dumpExceptionToFile(var7, "/home/loren/repos/d4jBugs/Math_45/version/XMLOut//out-RegressionTest1.test025.exception", false);
}
}
내 문제는 NumberIsTooLargeException
코드에서 try/catch 블록에 의해 삼킨 것입니다. (참고 : 예외 클래스는 모든 클래스가 될 수 있습니다. 이것은 문제가있는 사례의 한 예일뿐입니다.) 따라서 테스트 케이스를 생성하기 전에 try/catch 블록을 제거해야합니다.
javassist 또는 이것을 제거하기 위해 .java 파일에서 실행할 수있는 좋은 정규 표현식을 사용하는 사람은 누구입니까?
내가 끝낼 싶습니다
@Test
public void test025() throws Throwable {
try {
dumpObjectState.setDumpTestCase("RegressionTest1.test025");
if(debug) {
System.out.format("%n%s%n", new Object[]{"RegressionTest1.test025"});
}
Double[] var1 = new Double[]{Double.valueOf(1.0D), Double.valueOf(-1.0D)};
new ArrayRealVector(var1);
new ArrayRealVector(var1);
new ArrayRealVector(var1, 52, 32);
} catch (Exception var7) {
dumpObjectState.dumpExceptionToFile(var7, "/home/loren/repos/d4jBugs/Math_45/version/XMLOut//out-RegressionTest1.test025.exception", false);
}
}
Randoop와 --no-회귀 assertions'는 주장을 제거 할 필요가 없습니다해야'사용 : 전체 루프를 만드는
. – vinegarbin
사실, 우리 스크립트는 사전 작성된 테스트 케이스도 처리 할 수 있습니다.이 경우 수동으로 주석을 작성해야합니다. 또한, 원래의 테스트를 어설 션으로 실행하여 테스트를 수행하여 계측이 예상대로 작동하는지 확인하는 것이 좋습니다. – Loren